1. Andy Mikhailenko
  2. eav-django

Commits

Felipe Vieira  committed f105dc6

Added an way to define a fieldset to customize admin.

  • Participants
  • Parent commits a77108a
  • Branches default

Comments (0)

Files changed (1)

File eav/admin.py

View file
  • Ignore whitespace
 
 
 class BaseEntityAdmin(ModelAdmin):
+    eav_fieldsets = None
 
     def render_change_form(self, request, context, **kwargs):
         """
         """
         form = context['adminform'].form
 
-        # infer correct data from the form
-        fieldsets = [(None, {'fields': form.fields.keys()})]
+        if self.eav_fieldsets:
+          fieldsets = self.eav_fieldsets
+        # or infer correct data from the form
+        else:
+          fieldsets = [(None, {'fields': form.fields.keys()})]
+
         adminform = helpers.AdminForm(form, fieldsets,
                                       self.prepopulated_fields)
         media = mark_safe(self.media + adminform.media)