【问题标题】:Unable to load admin interface无法加载管理界面
【发布时间】:2013-05-22 23:25:44
【问题描述】:

我创建了一个新的 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',
)

网址

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']

【问题讨论】:

  • 添加django admin后需要syncdb。我猜你忘了这一步。 :)
  • 创建表 ... 安装自定义 SQL ... 安装索引 ... 从 0 个固定装置安装 0 个对象 完成 还是一样
  • Link。我认为这可能会有所帮助。

标签: django django-admin


【解决方案1】:

如果您只从项目中运行一个站点,则您实际上并不需要站点框架,因此最简单的解决方法是从您的 INSTALLED_APPS 中删除以下项目,并且错误应该会消失:

'django.contrib.sites'

您还可以从 shell 重新创建缺少的站点对象。运行 python manage.py shell 然后:

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

我想这可能会对你有所帮助。

【讨论】:

  • 如果我在 localhost 上使用它必须是什么域?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-23
  • 1970-01-01
  • 2019-06-08
  • 1970-01-01
  • 2011-12-26
  • 2014-06-17
  • 1970-01-01
相关资源
最近更新 更多