At the root page of the admin site where registered models appear, I want to hide several models that are registered to the Django admin.
If I directly unregister th
As of Django 1.8.18, has_module_permission() still has issue. So, in our case we used also the get_model_perms(). Likewise, we need to hide the model for specific user only, but the superuser should be able to access its index entry.
class MyModelAdmin(admin.ModelAdmin):
def get_model_perms(self, request):
if not request.user.is_superuser:
return {}
return super(MyModelAdmin, self).get_model_perms(request)
admin.site.register(MyModel, MyModelAdmin)