I use the following get_readonly_fields method to not allow editing objects in the django admin interface:
def get_readonly_fields(self, request, obj=None): if obj == None or request.user.is_superuser: return self.readonly_fields
This works fine, but save and save and continue editing are still displayed. They will not do anything, since all fields are read-only.
Therefore, my question is: is there a way to hide these save buttons depending on whether all fields are read-only or not? How could I implement this?
EDIT1:
I know how to override the admin/submit_line.html , but instead I would like to set show_save , show_save_as_new to False if I only have read-only fields. How to change these variable values?
source share