Re: How to define urls

2007-10-16 Thread James Bennett

On 10/16/07, Pythoni <[EMAIL PROTECTED]> wrote:
> Thanks a lot for help.It works well for , e.g. John Smith
> but what if  a user inserts  John.Smith  ( period instead of space)?
> I tried to add a period

This is the point where you really want to pause and read Python's
regular-expression documentation ;)

(understanding regexes is one of the fundamental "must-have" skills
for pretty much any sort of programming, and Django, with its
regex-based URLs, is no exception)

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: How to define urls

2007-10-16 Thread Jeremy Dunck

On 10/16/07, Pythoni <[EMAIL PROTECTED]> wrote:
...
> so I have in urls.py
> (r'^Myscript/(?P\w+)/','miproject.apps.mi.views.mi.Myscript'),
>
> it works only ifNameis one word, e.g. John.

You'll see documentation of python's re syntax here:
http://docs.python.org/lib/re-syntax.html

Based on that, \w is indeed only these chars:
[a-zA-Z0-9_]

You can extend the character class to accept spaces as well like so:
[\w ]+

So this would work for your purpose:
(r'^Myscript/(?P[\w ]+)/','miproject.apps.mi.views.mi.Myscript'),

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



How to define urls

2007-10-16 Thread Pythoni

Hi,
I need a URL like this
My script is called like this

http://myserver.com/Myscript/Name/

where name is a parameter

so I have in urls.py
(r'^Myscript/(?P\w+)/','miproject.apps.mi.views.mi.Myscript'),

it works only ifNameis one word, e.g. John.
If it is e.g.  John Smith it does not work.
How must I change that so that also spaces, in Name , will be
acceptable?
Thank you
B.


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