Skip to content

Commit

Permalink
Fix error on collection change (python3 only)
Browse files Browse the repository at this point in the history
Comparison with None type in python3 has been prohibited, which caused python to raise error `unorderable types: int() >= NoneType()` on line `if max_position >= updated >= min_position` when updated was None.
  • Loading branch information
akszydelko authored Dec 10, 2016
1 parent f0830ac commit ac03d82
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions positions/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ def pre_save(self, model_instance, add):
if updated is None:
updated = current
current = None
#elif updated is None:
# updated = -1

# existing instance, position not modified; no cleanup required
if current is not None and updated is None:
return current

# if updated is still unknown set the object to the last position,
# either it is a new object or collection has been changed
if updated is None:
updated = -1

collection_count = self.get_collection(model_instance).count()
if current is None:
max_position = collection_count
Expand Down

0 comments on commit ac03d82

Please sign in to comment.