我遇到这种情况我的注册页面在成功注册后就像http://localhost:8000/signUp?qid=ca1480f4
这样的网址提供了我想用这个查询将用户重定向到登录页面?qid=ca1480f4
views.py
class SignUp(FormView):
success_url = '/login'
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(self.get_success_url())
else:
return self.form_invalid(form)
我需要进行哪些更改才能使用self.request.META['QUERY_STRING']
答案 0 :(得分:3)
替换以下行:
return HttpResponseRedirect(self.get_success_url())
with(追加查询字符串):
return HttpResponseRedirect(self.get_success_url() + '?' + request.META['QUERY_STRING'])