Django项目/ admin站点匹配查询不存在 [英] Django project /admin Site matching query does not exist
问题描述
DoesNotExist at / admin /
站点匹配查询不存在。
事实上,我的项目/管理员在本地以及我的登台服务器上工作。它只是发生在我访问它,现在,我得到这个错误。
在查看SOF之后,我尝试使用以下命令运行python manage.py shell:
from django.contrib.sites.models import Site
Site.objects.create(pk = 1,domain ='www.xxx.com',name ='xxx.com')
,我将SITE_ID = 1更改为SITE_ID = www.mysite.com,刚刚结束了我的分段服务器,所以我更改了它,并再次尝试,而不改变SITE_ID。
可能是什么问题?
您的设置文件中的SITE_ID设置似乎指向数据库中不存在的ID。
您需要在网站模型中(通过管理员)创建新网站,并更改设置文件中的ID以匹配该网站,或重新插入项目通过SQL并将其设置为与设置文件相同的ID。
I am running a site live on heroku. My issuse occurs when I visit my site's admin located at www.mysite.com/admin. When I visit this page, I get
DoesNotExist at /admin/
Site matching query does not exist.
Thing is, my project /admin works locally as well as on my staging server. It just so happens when I visit it live, I get that error.
After looking around SOF, I tried doing running python manage.py shell with the following commands:
from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='www.xxx.com', name='xxx.com')
and I changed SITE_ID = 1 to SITE_ID = www.mysite.com and that just ended up breaking my staging server, so I changed it back and tried again without changing the SITE_ID.
What could be the issue?
It seems the SITE_ID setting in your settings file is pointing to an ID that doesn't exist in your database.
You either need to create a new site in the sites model (via admin) and change the ID in the settings file to match that one, or re-insert the item via SQL and give it the same ID as your settings file.
这篇关于Django项目/ admin站点匹配查询不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!