2

I think this should be fairly simple. I'm using Django Mezzanine CMS. I've created a page called "Calendar", and I have a page_processor that handles it. It takes a city/state argument like so:

http://localhost:8000/calendar/?city=Somerville,MA

What I would like instead is something like this:

http://localhost:8000/calendar/MA/Somerville

In my urls.py I have this:

url(r'^calendar/(?P<state>\w+$)', "mezzanine.pages.views.page", name="calendar"),                    
url(r'^calendar/(?P<state>\w+)/(?P<city>\w+)', "mezzanine.pages.views.page", name="calendar"), 

also for good measure:

url(r"^calendar/(.*)", "mezzanine.pages.views.page", name="calendar"), 

But I'm getting a 404. How do I map this?

TIA, Joel

user568259
  • 343
  • 1
  • 7
  • 16
  • 1
    I'm not familiar with mezzanine, but your url should work for the one that has `state` and `city` in there. Another possibility would be that there's some code in your `views.py` that does `get_object_or_404`. Is that possible? – Shang Wang Dec 15 '15 at 14:36
  • What order are these urls in your urls.py? – Sayse Dec 15 '15 at 14:37
  • The first URL passes the city as GET parameter while the second passes them as parameters to the function. I would guess, that Mezzanine does not have the view function that accepts these parameters or tries to find the ```city``` GET parameter and fails with a 404. – Tim Dec 15 '15 at 15:42
  • You're missing a trailing slash – kylieCatt Dec 15 '15 at 18:00

0 Answers0