Django admin unregister sites

I am trying to unregister for sites in django by doing the following:

from django.contrib.sites.models import Site

admin.site.unregister(Site)

However, this gives me a message that the "Site" is not registered (even if it appeared in the admins earlier).

If I try to do the following, I will not get errors, but the "Site" will remain in the admin panel:

from django.contrib.sites.models import Site

admin.site.register(Site)
admin.site.unregister(Site)

I need a site application and canโ€™t get it out of the INSTALLED_APPS settings. However, the admin is completely useless to me. Any ideas on what I'm doing wrong here?

Thank!

+4
source share
1 answer

The order of your setup is INSTALLED_APPSimportant.

Django , INSTALLED_APPS , (https://docs.djangoproject.com/en/1.11/ref/applications/#how-applications-are-loaded). Site, Django .

, . - , Django , , , -)

INSTALLED_APPS django.contrib, , . , .

+4
source

Source: https://habr.com/ru/post/1677944/


All Articles