标签:href lse method password post eve 使用 eth djang
1-关于用户登陆返回原访问登陆页面
一句话概括:在GET请求的时候获取一个原网页的链接, 之后再POST表单提交过之后,把这个原网页链接,拿过来使用
1 def register(request): 2 if request.method == ‘GET‘: 3 ret = render(request, ‘register.html‘) 4 ret.set_cookie(‘register_form‘, request.META.get(‘HTTP_REFERER‘, ‘/‘)) 5 return ret 6 else: 7 name = request.POST.get(‘name‘, ‘‘) 8 password = request.POST.get(‘password‘, ‘‘) 9 register_form = request.COOKIES.get(‘register_form‘, ‘‘) 10 if register_form: 11 ret = HttpResponse(f""" 12 返回原网页 13 <a href=‘{register_form}‘>点击返回原网页</a> 14 """) 15 ret.set_cookie(‘name‘, name) 16 print(register_form, ‘<<<<<<<<<<<<<register, 1‘) 17 return ret 18 else: 19 print(register_form, ‘<<<<<<<<<<<<<register, 0‘) 20 return redirect(reverse(‘index‘))
标签:href lse method password post eve 使用 eth djang
原文地址:https://www.cnblogs.com/impossible-g/p/9356283.html