Django - 站点匹配查询不存在 [英] Django - Site matching query does not exist
本文介绍了Django - 站点匹配查询不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
网站匹配查询不存在。
任何想法?
解决方案
每个django应用都需要一个站点
来运行。在这里你似乎没有。
登录到你的django shell
$> ./manage.py shell
>>>来自django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain ='example.com'
>>> site.name ='example.com'
>>> site.save()
或
$> ./manage.py shell
>>>来自django.contrib.sites.models import Site
>>> site = Site.objects.create(domain ='example.com',name ='example.com')
>>> site.save()
您应该全部设置。
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.
Any ideas ?
解决方案
Every django app needs a Site
to run. Here you do not seem to have it.
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()
or
$> ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> site = Site.objects.create(domain='example.com', name='example.com')
>>> site.save()
You should be all set.
这篇关于Django - 站点匹配查询不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文