Python 呼叫转移循环而不是重定向
我在django视图(django==2.1)中有一段代码,我想从子域重定向到主域Python 呼叫转移循环而不是重定向,python,django,url,redirect,subdomain,Python,Django,Url,Redirect,Subdomain,我在django视图(django==2.1)中有一段代码,我想从子域重定向到主域 def signup(request): current_site = Site.objects.get_current() if request.META['HTTP_HOST'] != current_site.domain: full = urljoin(current_site.domain, reverse('accounts:signup')) retu
def signup(request):
current_site = Site.objects.get_current()
if request.META['HTTP_HOST'] != current_site.domain:
full = urljoin(current_site.domain, reverse('accounts:signup'))
return HttpResponseRedirect(full)
不是重定向,而是重定向循环。而不是完整地址,而是结尾:/accounts/signup/
。
它应该是
http://localhost:8000/accounts/signup/
request.META['HTTP\u HOST']和当前站点.domain
的实际值是多少?request.META['HTTP\u HOST']-test2.localhost:8000
和current_site.domain-localhost:8000
对于sudomains,我想如果您检查或使用django主机会更好