I’m trying to make all fields readonly without listing them explicitly.
Something like:
class CustomAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
if request.user.is_superuser:
return self.readonly_fields
return self.fields
The problem is CustomAdmin.fields is not set at this point.
Any ideas?
Careful, self.model._meta.fields are not necessarily the same fields that CustomAdmin has!
“All fields of the Admin” would look more like this: