jpwatts / django-positions

A Django field for custom model ordering.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to append not prepend?

pcompassion opened this issue · comments

I'm perplexed because 'list' example and 'photo' example show different ordering behavior.

LIST

l.items.create(name='Write Tests')
<Item: Write Tests>

l.items.values_list('name', 'position')
[(u'Write Tests', 0)]

l.items.create(name='Excersize')
<Item: Excersize>

l.items.values_list('name', 'position').order_by('position')
[(u'Write Tests', 0), (u'Excersize', 1)]

PHOTO

bahamas = album.photos.create(name="Bahamas")
bahamas.position
0

jamaica = album.photos.create(name="Jamaica")
jamaica.position
0

grand_cayman = album.photos.create(name="Grand Cayman")
grand_cayman.position
0

cozumel = album.photos.create(name="Cozumel")
cozumel.position
0

album.photos.order_by('position').values_list('name', 'position')
[(u'Cozumel', 0), (u'Grand Cayman', 1), (u'Jamaica', 2), (u'Bahamas', 3)]

Their ordering is different.. Bahamas should be 0, is this just bug in the doc?

Oh, I get it, it's the 'default=0' I guess. It could have been a nice addition to the explanation.