Django管理员在/ admin /中不存在
我在Django管理员方面遇到一些问题。
在syncdb之后,结果是:
Creating tables ... Installing custom SQL ...
Installing indexes ...
No fixtures found.
这是什么意思?
无论如何,当我访问网站管理面板http://www.example.com/admin/时,我收到以下消息:
DoesNotExist at /admin/Site matching query does not exist.
setting.py包含:
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包含:
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)),
)
回答:
sites
如果你仅从项目中运行一个站点,则实际上并不需要该框架,因此最简单的解决方法是从你的项目中删除以下项目,INSTALLED_APPS
错误应消失:
'django.contrib.sites'
你也可以从shell重新创建缺少的Site对象。运行python manage.py shell,然后:
from django.contrib.sites.models import SiteSite.objects.create(pk=1, domain='www.example.com', name='example.com')
以上是 Django管理员在/ admin /中不存在 的全部内容, 来源链接: utcz.com/qa/414107.html