diff --git a/adminsortable2/admin.py b/adminsortable2/admin.py index 664d8ba..5647c30 100644 --- a/adminsortable2/admin.py +++ b/adminsortable2/admin.py @@ -485,10 +485,11 @@ def save_new(self, form, commit=True): """ obj = super().save_new(form, commit=False) - order_field_value = getattr(obj, self.default_order_field, None) - if order_field_value is None or order_field_value >= 0: - max_order = self.get_max_order() - setattr(obj, self.default_order_field, max_order + 1) + if self.default_order_field: + order_field_value = getattr(obj, self.default_order_field, None) + if order_field_value is None or order_field_value >= 0: + max_order = self.get_max_order() + setattr(obj, self.default_order_field, max_order + 1) if commit: obj.save() # form.save_m2m() can be called via the formset later on