Skip to content

Commit b54ffed

Browse files
authored
Merge pull request jrief#165 from meesterguyman/patch-1
Update admin.py
2 parents 03a6c03 + 3cb35b1 commit b54ffed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adminsortable2/admin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ def get_fields(self, request, obj=None):
413413
fields = super(SortableInlineAdminMixin, self).get_fields(request, obj)
414414
default_order_directions, default_order_field = _get_default_ordering(self.model, self)
415415

416-
if fields[0] == default_order_field:
416+
if not (default_order_field in fields):
417+
# If the order field is not in the field list, add it
418+
fields.append(default_order_field)
419+
elif fields[0] == default_order_field:
417420
"""
418421
Remove the order field and add it again immediately to ensure it is not on first position.
419422
This ensures that django's template for tabular inline renders the first column with colspan="2":

0 commit comments

Comments
 (0)