Django URL regex question
Posted
by shawnjan
on Stack Overflow
See other posts from Stack Overflow
or by shawnjan
Published on 2010-03-22T18:38:10Z
Indexed on
2010/03/22
18:41 UTC
Read the original article
Hit count: 647
Hey all!
I had a quick question about Django URL configuration, and I guess REGEX as well. I have a small configuration application that takes in environments and artifacts in the following way:
url(r'^env/(?P<env>\w+)/artifact/(?P<artifact>\w+)/$', 'config.views.ipview', name="bothlist"),
Now, this works fine, but what I would like to do is have it be able to have additional parameters that are optional, such as a verbose mode or no formating mode. I know how to do this just fine in the views, but I can't wrap my head around the regex.
the call would be something like
GET /env/<env>/artifact/<artifact>/<opt:verbose>/<opt:noformat>
Any help would be appreciated, thanks!
-Shawn
© Stack Overflow or respective owner