Re: Handling input of external urls

2010-02-28 Thread russianbandit
Thanks guys. It appears using URLField is the best answer here.
It automatically prepends http:// if the url doesn't include that.

On Feb 27, 7:27 pm, Prabhu  wrote:
> If you use URLField it should do the trick. Just prefix http:// if it
> doesn't exist already using javascript.
>
> On Feb 26, 9:37 pm, russianbandit  wrote:
>
> > This is a fairly general question, but what is the best way to handle
> > and verify user entry of external urls? For example, if the user types
> > in "google.com", django will try to render "http://localhost:8000/
> > users/google.com". That is obviously not what I want. I know that if
> > the user types in "http://google.com; the request will be forwarded
> > correctly to Google. Thus my question is, what is the right/best way
> > to handle user input of external urls?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Handling input of external urls

2010-02-27 Thread Prabhu
If you use URLField it should do the trick. Just prefix http:// if it
doesn't exist already using javascript.

On Feb 26, 9:37 pm, russianbandit  wrote:
> This is a fairly general question, but what is the best way to handle
> and verify user entry of external urls? For example, if the user types
> in "google.com", django will try to render "http://localhost:8000/
> users/google.com". That is obviously not what I want. I know that if
> the user types in "http://google.com; the request will be forwarded
> correctly to Google. Thus my question is, what is the right/best way
> to handle user input of external urls?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Handling input of external urls

2010-02-27 Thread rebus_
On 27 February 2010 02:17, russianbandit  wrote:
> Sorry for being sort of a newb when it comes to regex. But what
> exactly does that line do?
>
> On Feb 26, 3:59 pm, "ge...@aquarianhouse.com"
>  wrote:
>> Check it with regex?
>>
>> re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

well this regex would translate to:

any lowercase letter in range from a to z or digit appearing once
([a-z0-9]) followed by a literal dot (.) and then followed by 2 to 6
occurrences of any lowercase letter in range from a to z followed by
the end of the string.

But this regex doesn't seem all that useful, and it is not a raw string.

You could just check to see if the protocol was specified and based on
that append it or not.

r'^http:\\'

Google search for "url regex" gives:
http://www.geekzilla.co.uk/view2D3B0109-C1B2-4B4E-BFFD-E8088CBC85FD.htm

Learn more about regular expressions:
http://www.regular-expressions.info/reference.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Handling input of external urls

2010-02-26 Thread russianbandit
Sorry for being sort of a newb when it comes to regex. But what
exactly does that line do?

On Feb 26, 3:59 pm, "ge...@aquarianhouse.com"
 wrote:
> Check it with regex?
>
> re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Handling input of external urls

2010-02-26 Thread ge...@aquarianhouse.com
Check it with regex?

re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.