Don't apply a default value if the value is already specified

master
blag 2020-05-26 17:27:50 -07:00
parent 7deb73c806
commit 45b54a3402
No known key found for this signature in database
GPG Key ID: 30870D32F59C5F40
1 changed files with 1 additions and 1 deletions

View File

@ -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