Ticket #12628: generic-readonly.diff

File generic-readonly.diff, 1.0 KB (added by Alex Gaynor, 15 years ago)
  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index 0d542a4..4f15d41 100644
    a b class GenericInlineModelAdmin(InlineModelAdmin):  
    387387            fields = flatten_fieldsets(self.declared_fieldsets)
    388388        else:
    389389            fields = None
     390        if self.exclude is None:
     391            exclude = []
     392        else:
     393            exclude = list(self.exclude)
     394        exclude.extend(self.get_readonly_fields(request, obj))
     395        exclude = exclude or None
     396       
    390397        defaults = {
    391398            "ct_field": self.ct_field,
    392399            "fk_field": self.ct_fk_field,
    class GenericInlineModelAdmin(InlineModelAdmin):  
    398405            "can_order": False,
    399406            "fields": fields,
    400407            "max_num": self.max_num,
    401             "exclude": self.exclude
     408            "exclude": exclude
    402409        }
    403410        return generic_inlineformset_factory(self.model, **defaults)
    404411
Back to Top