【发布时间】:2021-01-28 09:15:21
【问题描述】:
我不知道这是错误还是功能,但是当我使用联系表单锚点在主页上时
(url = http://localhost:8000/#contact)
提交表单后,所有这些都会重定向,包括 #contact 锚名称,我无法摆脱它:
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.shortcuts import redirect
# Following 3 lines all send back to http://localhost:8000/#contact
return HttpResponseRedirect(reverse('homepage'))
return redirect(reverse('homepage'))
return redirect('/')
# As a test, the following line redirects to http://localhost:8000/account/email/#contact
return HttpResponseRedirect(reverse('account:email'))
我发现一些人有相反的问题,尝试add the anchor name,但找不到与我的问题相关的问题
【问题讨论】:
-
使用你要重定向到的路径名,并在重定向函数中使用