Reputation: 15434
When I try to GET /admin in my django project I get following error:
DoesNotExist at /admin/
Site matching query does not exist. Lookup parameters were {'pk': 1}
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.5
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist. Lookup parameters were {'pk': 1}
Exception Location: /Users/me/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/query.py in get, line 401
Python Executable: /Users/me/.virtualenvs/project/bin/python
It is strange because in settings.py
I do have:
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',
...
)
I run project using python manage.py runserver
and rest of my site is working except admin page... What might be a cause?
Upvotes: 0
Views: 657
Reputation: 199
It seems you are not using the sites framework and it is still included in the settings.
Just go to your settings.py file and comment the ''django.contrib.sites'(as shown below)
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
**#'django.contrib.sites',**
'django.contrib.messages',
'django.contrib.staticfiles',p
'django.contrib.admin',
This should work now. Also it will help if you upgrade your Django version to 1.6 (latest stable release). Just go to your command-line and type pip install django --upgrade to get the lastest Django stable version.
Upvotes: 0
Reputation: 2790
The problem seems to be with the fact that you are using the "sites framework" but didn't "create" a site in your database.
python manage.py syncdb
and then add a site to django_site
table with id=1
Upvotes: 1