Skip to content

Commit

Permalink
Enhanced admin list_display is now a tuple
Browse files Browse the repository at this point in the history
closes #183
  • Loading branch information
radiac committed Aug 15, 2024
1 parent 5133f81 commit fd2d6a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ are available by installing the develop branch from github.
Bugfix:

* Form field ``has_changed`` now correctly detects if a TagField has changed (#185)
* Admin enhance ensures ``list_display`` is a tuple (#183)

Thanks to:

* Christian Schneider (cnschn) for help fixing ``has_changed`` (#185)



2.0.0, 2024-08-13
-----------------

Expand Down
5 changes: 4 additions & 1 deletion tagulous/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_autocomplete_fields(self, request):
(tag_models.SingleTagField, tag_models.TagField),
)
]
return safe_fields
return tuple(safe_fields)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -232,6 +232,9 @@ def enhance(model, admin_class):
# Add display function to admin class
setattr(admin_class, display_name, _create_display(field))

# Make it immutable
admin_class.list_display = tuple(admin_class.list_display)

#
# If admin is for a tag model, ensure any inlines for tagged models are
# subclasses of TaggedInlineFormSet.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_register_tag_model_class_properties(self):
self.assertTrue(self.model.singletag.tag_model in self.site._registry)
ma = self.site._registry[self.model.singletag.tag_model]
self.assertIsInstance(ma, tag_admin.TagModelAdmin)
self.assertEqual(ma.list_display, ["name"])
self.assertEqual(ma.list_display, ("name",))
self.assertEqual(ma.list_filter, ["count"])
self.assertEqual(ma.exclude, ["name"])
self.assertEqual(ma.actions, [])
Expand Down

0 comments on commit fd2d6a1

Please sign in to comment.