Remove default apps from Django-admin

前端 未结 5 1724
無奈伤痛
無奈伤痛 2020-12-08 09:15

By default, in Django-admin there is Users, Groups, and Sites apps. How can I remove Groups and Sites?

I tried to remove admin.autodiscover() from root

5条回答
  •  天命终不由人
    2020-12-08 10:00

    Loop through all apps, and unregister any models they have registered.

    from django.apps import apps
    
    
    # De-register all models from other apps
    for app_config in apps.get_app_configs():
        for model in app_config.get_models():
            if admin.site.is_registered(model):
                admin.site.unregister(model)
    
    
    # Register only those models you want
    ...
    

提交回复
热议问题