Django - 站点匹配查询不存在 [英] Django - Site matching query does not exist
本文介绍了Django - 站点匹配查询不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在 Django 中获取我的应用程序的管理站点.我刚刚同步了数据库,然后去了网站,但我收到了错误......
Im trying to get the admin site of my app in Django working. Ive just sync`d the DB and then gone to the site but I get the error ...
Site matching query does not exist.
有什么想法吗?
推荐答案
每个 django 应用都需要一个 Site
来运行.在这里,您似乎没有.
Every django app needs a Site
to run. Here you do not seem to have it.
登录到你的 django shell
Log into your django shell
$> ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain = 'example.com'
>>> site.name = 'example.com'
>>> site.save()
或
$> ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site.objects.create(domain='example.com', name='example.com')
>>> site.save()
你应该准备好了.
这篇关于Django - 站点匹配查询不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文