mirror of
https://github.com/jazzband/django-admin-sortable.git
synced 2026-04-07 08:21:05 +00:00
Merge 52c05cbf93 into b9c1f3e0c4
This commit is contained in:
commit
91a0653757
2 changed files with 3 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
VERSION = (2, 3, 0)
|
||||
VERSION = (2, 3, 1)
|
||||
DEV_N = None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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