I have a django app with the following class in my admin.py:
class SoftwareVersionAdmin(ModelAdmin):
fields = (\"product\", \"version_number\", \"descrip
I don't think it's a good idea to override fields
or exclude
or form
, because they are config attributes, so they would not initialize for every request.
I think the accepted answer by shanyu is a good solution.
Or we can use the method from UserAdmin:
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super(UserAdmin, self).get_fieldsets(request, obj)
Remember to assign the add_fieldsets
yourself. Unfortunately it doesn't fit my use case.
For Django 1.7. I don't know how they are implemented in other versions.