I was assuming that get_fields
will behave the same as defining fields =
in the admin, but I get an error when trying to define tuples:
class ExampleAdmin(admin.ModelAdmin):
fields = [("a", "b"), "c", "d"]
works but
class ExampleAdmin(admin.ModelAdmin):
def get_fields(self, request, obj=None):
fields = ["c"]
if obj:
additional_fields = [("a", "b"), "d"]
fields.append(additional_fields)
return fields
produces: expected str instance, tuple found.
Is it not possible to group the items the same way I can group them in tuples when defining by hand? I just want to hide some fields during create
that I wish to show on change
.