0

I have created a new Django project where in I am able to access http://127.0.0.1:8000 but I can't access the admin dashboard http://127.0.0.1:8000/admin/.

INSTALLED APPS

INSTALLED_APPS = (
    'admin_tools',
    'admin_tools.theming',
    'admin_tools.menu',
    'admin_tools.dashboard',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    #'django.contrib.sites',

    'django.contrib.messages',
    'health',

    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
     'django.contrib.admindocs',
)

URLS

from django.conf.urls import patterns, include, url
from django.contrib import admin
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:

    # 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)),
    url(r'^$','authentication.views.login_authenticate'),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^admin_tools/', include('admin_tools.urls')),
)

Response

DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version: 1.4.2
Exception Type: DoesNotExist
Exception Value:    
Site matching query does not exist.
Exception Location: /Library/Python/2.6/site-packages/django/db/models/query.py in get, line 366
Python Executable:  /usr/bin/python
Python Version: 2.6.1
Python Path:    
['/Users/iceman/Documents/onkar_workspace/MyProject',
 '/Library/Python/2.6/site-packages/PyMySQL-0.5-py2.6.egg',
 '/Library/Python/2.6/site-packages/elementtree-1.2.7_20070827_preview-py2.6.egg',
 '/Library/Python/2.6/site-packages/Markdown-2.2.0-py2.6.egg',
 '/Library/Python/2.6/site-packages/xhtml2pdf-0.0.4-py2.6.egg',
 '/Library/Python/2.6/site-packages/pyPdf-1.13-py2.6.egg',
 '/Library/Python/2.6/site-packages/pytz-2012c-py2.6.egg',
 '/Library/Python/2.6/site-packages/django_bootstrap_toolkit-2.5.4-py2.6.egg',
 '/Users/iceman/Documents/epicomm/PRHealth',
 '/Users/iceman/Downloads/eclipse/plugins/org.python.pydev_2.7.0.2012110722/pysrc',
 '/Library/Python/2.6/site-packages/ipython-0.13-py2.6.egg',
 '/Library/Python/2.6/site-packages/icalendar-3.0.1b2-py2.6.egg',
 '/Library/Python/2.6/site-packages/reportlab-2.5-py2.6-macosx-10.6-universal.egg',
 '/Library/Python/2.6/site-packages/PIL-1.1.7-py2.6-macosx-10.6-universal.egg',
 '/Library/Python/2.6/site-packages/html5lib-0.95-py2.6.egg',
 '/Library/Python/2.6/site-packages/django_timepiece-0.5.2-py2.6.egg',
 '/Library/Python/2.6/site-packages/django_compressor-1.1.2-py2.6.egg',
 '/Library/Python/2.6/site-packages/django_selectable-0.4.1-py2.6.egg',
 '/Library/Python/2.6/site-packages/django_pagination-1.0.7-py2.6.egg',
 '/Library/Python/2.6/site-packages/python_dateutil-1.5-py2.6.egg',
 '/Library/Python/2.6/site-packages/distribute-0.6.28-py2.6.egg',
 '/Library/Python/2.6/site-packages/MySQL_python-1.2.4b4-py2.6-macosx-10.6-universal.egg',
 '/Users/iceman/Downloads/eclipse/plugins/org.python.pydev_2.7.0.2012110722/pysrc/pydev_sitecustomize',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
 '/Library/Python/2.6/site-packages',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip']
onkar
  • 4,427
  • 10
  • 52
  • 89
  • 2
    After adding django admin you need to syncdb. I guess you forgot to do that step. :) – iraycd May 28 '13 at 09:23
  • Creating tables ... Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s) Finished Still the same – onkar May 28 '13 at 11:01
  • [Link](http://stackoverflow.com/questions/11476210/getting-site-matching-query-does-not-exist-error-after-creating-django-admin). I think this might help. – iraycd May 28 '13 at 11:33

1 Answers1

0

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:

'django.contrib.sites'

You can also re-create the missing Site object from shell. Run python manage.py shell and then:

from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='www.xxx.com', name='xxx.com')

I guess this might help you.

iraycd
  • 892
  • 1
  • 8
  • 23