#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 | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by charettes):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Your fix won't work:
{{{
#!python
class A(object):
inlines = []
def __init__(self):
self.inlines = self.inlines or []
class B(A):
pass
B.inlines += [1]
b = B()
print b.inlines #[1]
print B.inlines #[1]
print A.inlines #[1]
}}}
If you want to achieve this behavior you should re-define inlines as an
empty list when subclassing ModelAdmin:
{{{
#!python
class A(object):
inlines = []
class B(A):
inlines = []
B.inlines += [1]
b = B()
print b.inlines #[1]
print B.inlines #[1]
print A.inlines #[]
}}}
I would say it's the expected behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/17380#comment:1>
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.