Ticket #6630: 03-use-core-fieldsets-in-admin.diff

File 03-use-core-fieldsets-in-admin.diff, 810 bytes (added by Petr Marhoun <petr.marhoun@…>, 14 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    a b  
    177177            return self.fieldsets
    178178        elif self.fields:
    179179            return [(None, {'fields': self.fields})]
     180        elif getattr(getattr(self.form, '_meta', None), 'fieldsets', None):
     181            fieldsets = []
     182            for name, options in self.form._meta.fieldsets:
     183                legend = options.get('legend')
     184                fields = [field for field in options['fields'] if field in self.form.base_fields]
     185                if fields:
     186                    fieldsets.append((legend, {'fields': fields}))
     187            return fieldsets
    180188        return None
    181189    declared_fieldsets = property(_declared_fieldsets)
    182190
Back to Top