Fixed #14496 -- Fixed conflict between ModelForm exclude and ModelAdmin readonly values. Thanks, Julien Phalip.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16602 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-08-12 14:14:49 +00:00
parent e912edec20
commit 3d027b72eb
3 changed files with 119 additions and 0 deletions

View file

@ -313,6 +313,24 @@ subclass::
For an example see the section `Adding custom validation to the admin`_.
.. admonition:: Note
If your ``ModelForm`` and ``ModelAdmin`` both define an ``exclude``
option then ``ModelAdmin`` takes precedence::
class PersonForm(forms.ModelForm):
class Meta:
model = Person
exclude = ['name']
class PersonAdmin(admin.ModelAdmin):
exclude = ['age']
form = PersonForm
In the above example, the "age" field will be excluded but the "name"
field will be included in the generated form.
.. attribute:: ModelAdmin.formfield_overrides
This provides a quick-and-dirty way to override some of the