That's most likely what I'm going to do, but from a purely academic
perspective (and because I love using regex to shorten things) I was
hoping someone might have an idea on how to accomplish what I'm going
for without splitting things up. ;)

On Jun 6, 6:42 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Sat, Jun 6, 2009 at 9:39 PM, bimsland <uzum...@gmail.com> wrote:
>
> > Working on making some URLs on a project of mine ReSTful, and decided
> > to go with the filename extensions route for specifying content-type.
>
> > I've got a view named concerts, and to keep backwards compatibility, I
> > need to make sure the old URLs still work.  I need the urlpattern to
> > match...
>
> > ^/concerts
> > ^/concerts/
> > ^/concerts.html
> > ^/concerts/123
> > ^/concerts/123/
> > ^/concerts/123.html
>
> > The regex I wrote up to do this is...
>
> > ^/concerts(?:/(?P<id>\d+))?(?:/|\.(?P<format>\w{4}))?$
>
> > Which matches everything perfectly when going forward, but any attempt
> > to use reverse fails with a NoReverseMatch exception, any ideas on an
> > alternate regex or the correct way to reverse this?
>
> > The reverse call I'm using is...
>
> > reverse('concerts', kwargs={'id': concert.id, 'format': format})
>
> > Thanks!
>
> Split it up into several regexes which all point to the same view, but have
> different names.  That's going to be the easiest way, and you don't have to
> worry about the complexity of the regex anymore :)
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to