创建django管理后,获取站点匹配查询不存在错误 [英] Getting Site Matching Query Does Not Exist Error after creating django admin
问题描述
我将通过标准的Django教程来创建应用程序的管理员。评论管理相关的东西在设置和运行syncdb我得到这个消息:
I'm going through the standard Django tutorial to create an admin for an app. After commenting the admin related stuff in settings and running syncdb I'm getting this message:
DoesNotExist at /admin/ Site matching query does not exist.
任何人都可以帮我看看吗?
Can anyone help me figure this out?
推荐答案
缺少您的Django项目的站点
对象。每个Django项目都有一个站点
对象,其中包含站点的名称和域。通常在创建Django项目时会自动创建(特别是当 syncdb
命令运行时),但在您的情况下似乎没有发生。
The Site
object for your Django project is missing. Each Django project has a Site
object which contains the site's name and domain. It is usually automatically created when creating a Django project (in particular, when the syncdb
command runs) but in your case it seems that didn't happen.
要解决它:
为您的网站打开Django shell( python manage.py shell
)。
Open the Django shell for your site (python manage.py shell
).
键入以下内容:
>>> from django.contrib.sites.models import Site
>>> Site.objects.create(name='example.com', domain='example.com')
如果要稍后更改这些值,请转到管理面板( / admin /
),然后在 Sites
。
If you want to change these values later, go to your admin panel (/admin/
) and edit the site object in the section Sites
.
这篇关于创建django管理后,获取站点匹配查询不存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!