I solved this by putting the logic to install self.inline_instances = []in the method get_readonly_fields(self, request, obj=None).
For example, if you want to show inline strings for superusers, but not for anyone else:
def get_readonly_fields(self, request, obj=None):
if request.user.is_superuser:
return ()
else:
self.inline_instances = []
return ()
source
share