导入django.contrib.sites和 进行迁移我在尝试登录项目中的管理站点时遇到此错误
请求方法:GET
请求网址:http://127.0.0.1:8000/admin/login/?next=/admin/
Django版本:1.8.2
异常类型:DoesNotExist
例外价值:
站点匹配查询不存在。
异常位置:/usr/lib/python2.7/site-packages/django/db/models/query.py in get,line 334
它无法识别模式。我不知道网址是否有问题,所以我把代码放在这里。
web / urls.py(应用设置)
from django.conf.urls import patterns, include, url
urlpatterns = patterns('web.views',
# url(r'^$','index_view',name='vista_principal'),
# url(r'^about/$','about_view',name='vista_about'),
url(r'^$','index',name='home'),
url(r'^Ciudad/$','Ciudad_view',name='vista_Ciudad'),
url(r'^Plan/$','Plan_view',name='vista_Plan'),
url(r'^addTitular/$','addTitular',name='addTitular'),
url(r'^servicio/$','Parentesco',name='parentesco'),
url(r'^cargo/$','Cargo',name='cargo'),
url(r'^addEmpleado/$','addEmpleado',name='addEmpleado'),
url(r'^parentesco/$','Parentesco',name='parentesco'),
url(r'^addAfiliado/$','addAfiliado',name='addAfiliado'),
url(r'^addCobro/$','addCobro',name='addCobro'),
url(r'^consultarEmpleado/$','consultarE',name='consultarEmpleado'),
)
' global' /urls.py(项目设置)
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
urlpatterns = [
# Examples:
# url(r'^$', 'fun.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^',include('web.urls')),
url(r'^',include('usuarios.urls')),
url(r'^',include('registration.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
答案 0 :(得分:1)
它正在识别URL,但它正试图在某个地方对某个站点对象进行查询而没有找到它。
这可能是由各种各样的事情引起的,例如当你有另一个依赖于拥有网站的包时。对我来说,django-allauth通常是罪魁祸首,但是你没有这些信息所以我无法确定。
在您的设置中,尝试将SITE = 1
放入您的设置文件中,看看是否能解决您的错误。