configure url

22 views
Skip to first unread message

luca72

unread,
Nov 6, 2012, 9:36:50 AM11/6/12
to django...@googlegroups.com
Hello
I have to take a page with 4 variable that can be string number or mixed including point how i have to configure the url:

(r'^scarico/./././.','prova.views.scarico')

How i have to do it?

Thanks

Luca

Elena Williams

unread,
Nov 6, 2012, 11:43:26 AM11/6/12
to django...@googlegroups.com
Hi Luca,

Is the answer you're looking for something like this?:

(r'^scarico/(?P<var1>\w+)/(?P<var2>\w+)/(?P<var3>\w+)/(?P<myvar4>\w+)/$','prova.views.scarico')


Where \w+ is regex for anything except white-space ()

If you're using functional views the def would look as follows:

def scarico(request, var1, var2, var3, myvar4):
    ...
    return HttpResponse(...)

or alternatively if the variables are optional:

def scarico(request, var1=None, var2=None, var3=None, myvar4=None):
    ...


Regards,
Elena :)




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NSXBecUi1m4J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Message has been deleted

bruno desthuilliers

unread,
Nov 15, 2012, 4:01:00 AM11/15/12
to django...@googlegroups.com, richard...@lavabit.com
On Thursday, November 15, 2012 7:25:28 AM UTC+1, rh wrote:
All the tutorials I looked at didn't explain (?P<var1>\w+) and it seems that the
tutorials say things like "it's a regular expression, go read python docs for more".
Maybe regexs are consider ugly plumbing stuff unsuitable for tutorials.


Django is a framework, and the django documentation documents the framework - not the underlying language, which already has it's own doc AND a tutorial :

http://docs.python.org/2.7/library/re.html#module-re
http://docs.python.org/2.7/howto/regex.html#regex-howto




Reply all
Reply to author
Forward
0 new messages