#17380: Default value of ModelAdmin.inlines can be altered.
-------------------------------+--------------------
Reporter: schinckel | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.3
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Because ModelAdmin.inlines is defined as an empty list, if you have not
altered this in a ModelAdmin subclass, and then add to it, you actually
add that inline to every ModelAdmin subclass that does not override
inlines.
class MyModelAdmin(admin.ModelAdmin):
pass
if 'other_app' in settings.INSTALLED_APPS:
MyModelAdmin.inlines += [OtherInline]
This bug rears its head if you try to add two (or more) inlines to
UserAdmin.
I do have what seems like a fix: in ModelAdmin.__init__(), we can do:
self.inlines = self.inlines or []
This will set self.inlines to a new empty list if the original value was
falsy.
--
Ticket URL: <https://code.djangoproject.com/ticket/17380>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.