一尘不染

Django管理员在/ admin /中不存在

django

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

阅读 450

收藏
2020-03-29

共1个答案

一尘不染

sites如果你仅从项目中运行一个站点,则实际上并不需要该框架,因此最简单的解决方法是从你的项目中删除以下项目,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.example.com', name='example.com')
2020-03-29