Thursday, October 9, 2014

Re: cant pass the "CSRF verification failed. Request aborted." error

Ah....   nice trick, store the variables into the url and then pass the url with some regular expression.
=)



def vote(request):
   
if request.method == "POST":
        form
= polls.forms_DK.NameForm(request.POST)
       
if form.is_valid():
            your_email = form.cleaned_data["your_email"]
            ratio = str(form.cleaned_data["ratio"])
            adress = "thanks/"+your_email+"/"
           
return HttpResponseRedirect(adress)
   
else:
        form
= polls.forms_DK.NameForm()
    django
.setup()
    all_restaurants
= Restaurant.objects.all()
   
#return render_to_response("vote_form.html", {"all_restaurants": all_restaurants, "form": form})
   
return render(request, "vote_form.html", {"all_restaurants": all_restaurants, "form": form})


ok now to learn how to catch that url
will something like this would work?
url(r'^thanks/(?P<your_email>w+)/$', views.thanks),


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f906713c-6b72-4353-8d12-c0c45982c9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment