using get_fields results in different behavior than fields = [...]

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"]
        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.

You’ve got an extra set of parens in your append statement. It should be:

fields.append(["a", "b"])

I did that intentionally. I want to hand it a tuple, so the items appear on the same line in the admin form?

Then it’s: fields.append(("a", "b")). Either way, you had your data structure nested one level too deep.

you are obviously right. Thanks!