Home:ALL Converter>Django admin DoesNotExist at /admin/

Django admin DoesNotExist at /admin/

Ask Time:2012-03-16T20:10:05         Author:creative creative

Json Formatter

I have some problems with Django admin.

after syncdb, the result is:

  Creating tables ...
  Installing custom SQL ...
  Installing indexes ...
  No fixtures found.

What does this mean?

Anyway, when I visit the website admin panel http://www.example.com/admin/, I receive this message:

DoesNotExist at /admin/
Site matching query does not exist.

setting.py contains:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
)

ur.py contains:

from django.conf.urls.defaults import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'rshd.views.home', name='home'),
    # url(r'^rshd/', include('rshd.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
)

Author:creative creative,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/9736975/django-admin-doesnotexist-at-admin
zh0r1k :

just fixed the issue by an another way:\n\nI use PostgreSQL and Django 1.45...\nas i removed the www.example.com Site and added a new www.xxx.com Site it was added as ID=2\n'cause PostgreSQL doesn't go back in the ID numbers and the login and logout Django-Sites are somehow bound only to the ID=1 Site in your DB...\n\nI went to my PostgreSQL DB and changed the ID of www.xxx.com to 1 and then I was able to see the login and logout Site again :)\n\nbtw. [yes, you just can remove the django.contrib.sites from your settings.py if you don't need it ^^ (but I haven't tried this one out in my case, with the ID number problem)]\n\nhope it will work for further users! ;)",
2013-03-01T08:40:11
Lonwè SIMTADO :

Yes change the SITE_IT=1 to SITE_ID=2 and everything is ok",
2018-10-23T10:21:44
delvh :

Yes, the solution mentioned at the top can be (part of) the solution.\nI've noticed however, that not only including django.contrib.sites without configuration can cause that problem, also including any site of\nallauth (pip install django-allauth) might cause this problem if said package is not configured correctly.\n(And allauth is as far as I've seen not configured correctly by default...)",
2020-08-25T14:01:25
SASIN NISAR83 :

Another thing you can do is simple if you get some error or just want to change site.\n\nDownload sqlitebrowser \nopen your sqlite.db\nsearch for django_sites\nchange domain name and display name to whatever you want\n",
2021-04-09T10:39:47
Ramandeep Singh :

You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:\n\n'django.contrib.sites'\n\n\nYou can also re-create the missing Site object from shell. Run python manage.py shell and then:\n\nfrom django.contrib.sites.models import Site\nSite.objects.create(pk=1, domain='www.example.com', name='example.com')\n",
2012-03-16T12:36:04
Tarek Kalaji :

You can fix this error if you are using django.contrib.sites without removing it by changing SITE_ID = 1 value in settings.py file.\n\nIt is happen to me when I changed domain name on my server, I deleted old domain name from http://mynewdomainname.com/admin/sites/site/ manually, and the old domain record in database has id = 1, also I added new domain name mynewdomainname.com and it is id was id = 2, \nI just changed to SITE_ID = 2 and the error gone SITE_ID refers to current \"pk\" of active domain name you use as default.\nIn code:\n\n>>> from django.contrib.sites.models import Site\n>>> # get_current() came from SiteManager class manager, \n>>> # see site-packages/django/contrib/sites/models.py\n>>> current_site = Site.objects.get_current()\n>>> print(current_site.pk)\n2\n>>> print(current_site.domain)\n'http://mynewdomainname.com'\n\n\nthis happen after settings.py changed\n\nSITE_ID = 2\n\n\nBe careful about current domain id in django sites app.",
2018-01-25T09:06:34
dphacker :

The same problem also suddenly came to me, and you know there're many solutions. However, what's the reason of this sudden problem?\n\nAfter dig in deeply, I found the reason is that, we ignored a step in the first syncdb action.\n\nWhen you have your first syncdb, django will ask you to create a default account, if you don't input in this interactive show, that site object would not be created automatically.\n\nSo be careful of this. I'm using django 1.3.1, don't know whether the latest version has resolved this issue.",
2013-03-15T07:22:22
Lewy Blue :

Since the above comments are pretty old and the syncdb command doesn't exist, and I don't want to remove django.contrib.sites, here's what worked for me:\n\nIncrement SITE_ID. I had SITE_ID = 1, changed it to SITE_ID = 2 and everything worked again.",
2018-04-30T04:55:37
lwairore :

Add SITE_ID = 1 in your settings.py",
2019-09-13T12:50:41
yy