Friday, October 10, 2014

Re: best aproach to pass an email from the url to a view?

WOW SUPER EASY!!!!
I been fighting to the get the email and passing it

thanks for the tips, and how to use it.


my url
url(r'^vote/thank/$', views.thank),


my views

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 = "thank/?email="+your_email+"/" # here I make the URL
           
return HttpResponseRedirect(adress)
   
else:
        form
= polls.forms_DK.NameForm()
    django
.setup()
    all_restaurants
= Restaurant.objects.all()
   
return render(request, "vote_form.html", {"all_restaurants": all_restaurants, "form": form})

def thank(request, your_email=None): # I don't need your_email=None
    c
= {"thanks_body": "thanks_body view"} # I can rearenge the dictonary
   
remail = request.GET["email"] #here I pick up the email
    c
["thanks_body"] = remail
   
return render(request, "thanks.html", c)


--
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/32aa270f-fd9e-44b6-b8fc-cea6ff7706ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment