From be90eadfb98b7f7115a5e19e141e522aefd3f69f Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 1 Feb 2010 14:13:21 +0000 Subject: [PATCH] Fixed #12628 - Don't ignore read-only fields in GenericInlineModelAdmin during save. Thanks, Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12367 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/contenttypes/generic.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index 705b62e7cf..602b337e6b 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -379,6 +379,12 @@ class GenericInlineModelAdmin(InlineModelAdmin): fields = flatten_fieldsets(self.declared_fieldsets) else: fields = None + if self.exclude is None: + exclude = [] + else: + exclude = list(self.exclude) + exclude.extend(self.get_readonly_fields(request, obj)) + exclude = exclude or None defaults = { "ct_field": self.ct_field, "fk_field": self.ct_fk_field, @@ -390,7 +396,7 @@ class GenericInlineModelAdmin(InlineModelAdmin): "can_order": False, "fields": fields, "max_num": self.max_num, - "exclude": self.exclude + "exclude": exclude } return generic_inlineformset_factory(self.model, **defaults)