我创建了一个新的Django项目,我可以访问http://127.0.0.1:8000
但我无法访问管理信息中心http://127.0.0.1:8000/admin/
。
已安装的应用
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')),
)
响应
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']
答案 0 :(得分:0)
如果您只从项目中运行一个站点,则不需要站点框架,因此最简单的修复方法是从INSTALLED_APPS中删除以下项目,错误应该消失:
'django.contrib.sites'
您还可以从shell重新创建缺少的Site对象。运行python manage.py shell然后:
from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='www.xxx.com', name='xxx.com')
我想这可能会对你有帮助。