Django管理员不要在/ admin / [英] Django admin DoesNotExist at /admin/

查看:224
本文介绍了Django管理员不要在/ admin /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ db
$ b

在syncdb之后,结果是:

 创建表... 
安装自定义SQL ...
安装索引...
找不到灯具。

这是什么意思?



当我访问网站管理面板 http://www.example.com/admin/ 时,我收到此消息:

  DoesNotExist at / admin / 
站点匹配查询不存在。

setting.py包含:

  INSTALLED_APPS =(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#取消注释下一行以启用管理员:
'django.contrib.admin',

ur.py包含: p>

 从django.conf.urls.defaults导入模式,include,url 

#取消注释接下来的两行启用admin:
从django.contrib import admin
admin.autodiscover()

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

#取消注释下面的admin / doc行以启用管理员文档:
url(r'^ admin / doc /',include('django.contrib.admindocs.urls')),

#取消注释下一行以启用admin:
url(r'^ admin /' ,include(admin.site.urls)),


解决方案

如果您只从项目中运行一个网站,您不需要网站框架,因此最简单的修复将是删除以下项目从您的 INSTALLED_APPS ,错误应该消失:

 'django.contrib.sites'

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

 从django.contrib.sites.models导入站点
Site.objects .create(pk = 1,domain ='www.example.com',name ='example.com')


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)),
)

解决方案

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.example.com', name='example.com')

这篇关于Django管理员不要在/ admin /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆