mirror of
https://github.com/jazzband/django-admin-sortable.git
synced 2026-04-22 15:34:44 +00:00
Fix bug when order value is zero
Bug: when order value is zero, a new order value is generated
This commit is contained in:
parent
b9c1f3e0c4
commit
b55f5e7801
1 changed files with 2 additions and 1 deletions
|
|
@ -89,7 +89,8 @@ class SortableMixin(models.Model):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
needs_default = (self._state.adding if VERSION >= (1, 8) else not self.pk)
|
||||
if not getattr(self, self.order_field_name) and needs_default:
|
||||
order_value = getattr(self, self.order_field_name)
|
||||
if order_value is None and needs_default:
|
||||
try:
|
||||
current_max = self.__class__.objects.aggregate(
|
||||
models.Max(self.order_field_name))[self.order_field_name + '__max'] or 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue