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
Based on x0nix's answer I did some experiments. It seems like returning an empty dict from get_model_perms
excludes the model from index.html, whilst still allowing you to edit instances directly.
class MyModelAdmin(admin.ModelAdmin):
def get_model_perms(self, request):
"""
Return empty perms dict thus hiding the model from admin index.
"""
return {}
admin.site.register(MyModel, MyModelAdmin)
Django 1.2 has new if-statements, meaning that the desired feature could be obtained only by overwriting admin/index.html
{% if model.name not in "Name of hidden model; Name of other hidden model" %}
...
{% endif %}
This is a bad solution, because it doesn't care about multi-language admins. You could of course add the names of models in all of the supported languages. It's a good solution because it doesn't overwrite more than one aspect of core Django functions.
But before changing anything, I think people should think about this...
Essentially the problem is related to having models that one does not wish to use for more than adding an option to a drop-down once in a while. It could effectively be worked around by creating a set of permissions for "not so advanced" users that panic when there are too many models. In case changes in the particular models are required, one can simply log in with the "advanced account".