Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 呼叫转移循环而不是重定向_Python_Django_Url_Redirect_Subdomain - Fatal编程技术网

Python 呼叫转移循环而不是重定向

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

我在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'))
        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主机会更好