#29917: admin.E130 (__name__ uniqueness) regression -------------------------------------+------------------------------------- Reporter: Matthias Kestenholz | Owner: nobody Type: Bug | Status: new Component: contrib.admin | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Matthias Kestenholz): It's quite interesting. Django does not have any tests verifying the MRO behavior. The complete test suite still passes after applying the following patch: {{{ diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 241d22e82a..07521e3df3 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -862,9 +862,11 @@ class ModelAdmin(BaseModelAdmin): - # Then gather them from the model admin and all parent classes, - # starting with self and working back up. - for klass in self.__class__.mro()[::-1]: - class_actions = getattr(klass, 'actions', []) or [] - actions.extend(self.get_action(action) for action in class_actions) + actions.extend(self.get_action(action) for action in (getattr(self, 'actions', None) or [])) # get_action might have returned None, so filter any of those out. return filter(None, actions) }}} People might rely on it though, so silently introducing this change is out of the question. I propose the following changes to Django: - Apply the patch above. - Add a new system check which warns users when the `actions` attribute of registered model admin classes does not contain a superset of the `actions` attribute of all it's bases (recursively). This cannot be made an error because actions might be excluded on purpose. - I'm not sure whether documentation changes are necessary -- this proposal does not change documented behavior (AFAIK) -- Ticket URL: <https://code.djangoproject.com/ticket/29917#comment:6> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.68ebd30d5c22eda9f452b9cb03e65932%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.