summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-08-12 14:14:49 +0000
committerJannis Leidel <jannis@leidel.info>2011-08-12 14:14:49 +0000
commit3d027b72ebaf3fa41c9f6c17873fe3cee08d9007 (patch)
tree0bf5fd2433e4b72c1b40d8b8916212f46af653b6 /django
parente912edec20f4d81d1b5c1a02bede1632f3beaa83 (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/contrib/admin/options.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 922205f8cd..cf7ea83c11 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -437,6 +437,10 @@ class ModelAdmin(BaseModelAdmin):
else:
exclude = list(self.exclude)
exclude.extend(self.get_readonly_fields(request, obj))
+ if self.exclude is None and hasattr(self.form, '_meta') and self.form._meta.exclude:
+ # Take the custom ModelForm's Meta.exclude into account only if the
+ # ModelAdmin doesn't define its own.
+ exclude.extend(self.form._meta.exclude)
# if exclude is an empty list we pass None to be consistant with the
# default on modelform_factory
exclude = exclude or None
@@ -1343,6 +1347,10 @@ class InlineModelAdmin(BaseModelAdmin):
else:
exclude = list(self.exclude)
exclude.extend(self.get_readonly_fields(request, obj))
+ if self.exclude is None and hasattr(self.form, '_meta') and self.form._meta.exclude:
+ # Take the custom ModelForm's Meta.exclude into account only if the
+ # InlineModelAdmin doesn't define its own.
+ exclude.extend(self.form._meta.exclude)
# if exclude is an empty list we use None, since that's the actual
# default
exclude = exclude or None