jpwatts / django-positions

A Django field for custom model ordering.
BSD 3-Clause "New" or "Revised" License
284 stars 71 forks source link

fix for adding a position with value 0 #7

Closed smulloni closed 14 years ago

smulloni commented 14 years ago

At the moment, if you add a new item with position 0, the new item is added at the end as if one had entered -1. This is because the "updated" variable in pre_save is evaluated as a boolean at one point rather than checking if it is None.

Here's the one-line fix. I'd really appreciate a merge -- thanks!

jpwatts commented 14 years ago

Thanks for the fix. That should definitely be an identity test, rather than a truth test.

I had a little trouble reproducing your problem; it seems to only come up when you initialize an instance with the default position and then explicitly set it to zero before saving. I finally tracked it down and added a test for it in b8cf3ca47e1a8052754cd1b27eb7114c3e6b95e9.