mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
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:
parent
e912edec20
commit
3d027b72eb
3 changed files with 119 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue