I am using django 1.4 and I have a many2many field, so when creating the admin site I wanted to add this field as an inline, here is some code:
class SummaryInli
You can make the entire inline readonly by adding:
class UnitsInline(admin.TabularInline):
def has_change_permission(self, request, obj=None):
return False
This will prevent anyone from editing the entry from the admin.
Another example that prevents, adding, deletion and displays all the inline fields as readonly:
class ReadOnlyInline(admin.TabularInline):
def has_change_permission(self, request, obj=None):
return False
def has_add_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False
def get_readonly_fields(self, request, obj=None):
return list(super().get_fields(request, obj))