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

2014-10-10 Thread Javier Guerra Giraldez
On Fri, Oct 10, 2014 at 6:21 PM, dk  wrote:
> I been fighting to the get the email and passing it


if you want to keep a value from one request to another, check the
Session feature.  In short, it works (almost) like a persistent
dictionary private for each web user.

-- 
Javier

-- 
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+unsubscr...@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/CAFkDaoRqLOfmOvxagPFT0msRRR85MNiMis2KaWT_LgfR_i4OsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-10 Thread dk
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+unsubscr...@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.


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

2014-10-10 Thread Daniel Roseman
On Friday, 10 October 2014 01:00:29 UTC+1, dk wrote:
>
> I put the Email that I got from a form into the url (I am using the url as 
> a variable to store the email)
>
> and look like this
> http://127.0.0.1:8000/polls/vote/thank/a...@b.com/
>
>
> url:
> url(r'^vote/thank/(?   #here should be RE catching the email 
>)$', views.thank),
> view:
> def thank(request, your_email=None):
> c = {"thanks_body": "thanks_body view"}
> c["his_email"] = your_email
> return render(request, "thanks.html", c)
>
> I am having issues to try to come up with a RE to grab the email
> I try 
> http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
> using it on my url
> such 
> url(r'^vote/thank/(?
> *^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$* ', 
> views.thank),
>  and I still don't catch it, I think because I am just copy pasting but in 
> the url string should be arrenge diferntly?
> I was reading about a  get function that can make a quary on the url like 
> a dictionary?  any example on how to use it?
>
> thanks,  (I order a book for RE  =)  just to be able to udertand a little 
> bit more   )
>
>

I think you're trying too hard here. Regexes for email are usually 
concerned with *validation*, ie checking in a form that the thing typed 
into the "email" field looks like an actual email. But that is not, or 
should not be, a consideration in a URL: at this point the email has 
already been validated, and all you want to do is to send it to the next 
page. So you probably just want to grab everything after the `thank` part:

'^vote/thank/(?.*)$'

To be honest though, this is something I wouldn't even try to catch in the 
URL at all. Instead, pass it as a querystring parameter, so the URL would 
be in the format "/vote/thank/?email=f...@bar.com" and you get it in the 
view as `request.GET['email']`.
--
DR>

-- 
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+unsubscr...@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/9ad145a3-08f2-4144-bbc6-75fb949b1184%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-10 Thread James Schneider
Try adding a capital P after the ? in your named capture group.

Otherwise your capture group does not place its value in the your_email
variable as you are expecting:

(?P...


Check out the Python re module syntax for an explanation:

https://docs.python.org/2/library/re.html

-James

On Thursday, October 9, 2014, dk  wrote:

> I put the Email that I got from a form into the url (I am using the url as
> a variable to store the email)
>
> and look like this
> http://127.0.0.1:8000/polls/vote/thank/a...@b.com/
>
>
> url:
> url(r'^vote/thank/(?   #here should be RE catching the email
>)$', views.thank),
> view:
> def thank(request, your_email=None):
> c = {"thanks_body": "thanks_body view"}
> c["his_email"] = your_email
> return render(request, "thanks.html", c)
>
> I am having issues to try to come up with a RE to grab the email
> I try
> http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
> using it on my url
> such
> url(r'^vote/thank/(?
> *^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$* ',
> views.thank),
>  and I still don't catch it, I think because I am just copy pasting but in
> the url string should be arrenge diferntly?
> I was reading about a  get function that can make a quary on the url like
> a dictionary?  any example on how to use it?
>
> thanks,  (I order a book for RE  =)  just to be able to udertand a little
> bit more   )
>
>
>
>  --
> 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+unsubscr...@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/b84874c3-32ad-47fb-82db-5e48b87a975d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@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/CA%2Be%2BciUX_d%2BEay9%3DrjqcmpyHvm32eqBNH-eO%2B4WmX5by9oDX4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.