Don't apply a default value if the value is already specified
parent
7deb73c806
commit
45b54a3402
|
|
@ -89,7 +89,7 @@ class SortableMixin(models.Model):
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
needs_default = (self._state.adding if VERSION >= (1, 8) else not self.pk)
|
needs_default = (self._state.adding if VERSION >= (1, 8) else not self.pk)
|
||||||
if needs_default:
|
if not getattr(self, self.order_field_name) and needs_default:
|
||||||
try:
|
try:
|
||||||
current_max = self.__class__.objects.aggregate(
|
current_max = self.__class__.objects.aggregate(
|
||||||
models.Max(self.order_field_name))[self.order_field_name + '__max'] or 0
|
models.Max(self.order_field_name))[self.order_field_name + '__max'] or 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue