URL Parameters for a Page

175 views
Skip to first unread message

Joel Gwynn

unread,
Dec 13, 2015, 8:35:44 AM12/13/15
to Mezzanine Users
I think this should be fairly simple.  I've created a page called "Calendar", and I have a page_processor that handles it.  It takes a city/state argument like so:


What I would like instead is something like this:


In my urls.py I have this:

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

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

TIA,
Joel

Nkansah Rexford

unread,
Dec 15, 2015, 2:22:53 AM12/15/15
to Mezzanine Users

Joel Gwynn

unread,
Dec 15, 2015, 8:43:01 AM12/15/15
to Mezzanine Users
Thanks for the purple link, Mr. Rexford.  I have spent quite some time on that page, and it seems like my rule should work, but alas, here we are.

Ken Bolton

unread,
Dec 15, 2015, 9:53:24 AM12/15/15
to mezzanine-users
Hi Joel,

What does your page processor code look like? My instinct is that a calendar is not a page and should probably not use the page view.

Please accept every attempt at communication on this forum in good faith and, in the future, hold the sarcasm.

ken

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joel Gwynn

unread,
Dec 15, 2015, 10:12:22 AM12/15/15
to Mezzanine Users
Sorry about that.

The calendar is a page that I created through the admin interface, and the page processor looks like this:

@processor_for("calendar")
def location(request, page):

Joel Gwynn

unread,
Dec 15, 2015, 10:14:14 AM12/15/15
to Mezzanine Users
Sorry, looks like I posted accidentally.  At any rate, below you can see the processor method.  It does get called when I hit the page: http://localhost:8000/calendar/?city=Somerville,MA

Joel Gwynn

unread,
Dec 15, 2015, 10:24:59 AM12/15/15
to Mezzanine Users
Upon closer inspection, the 404 is:
 
Request Method:GET
Request URL:http://localhost:8000/calendar/MA
Raised by:mezzanine.pages.views.page

So it seems that maybe the url rule is being called, but views.py isn't able to find the page.


On Tuesday, December 15, 2015 at 10:12:22 AM UTC-5, Joel Gwynn wrote:

Ken Bolton

unread,
Dec 15, 2015, 11:12:02 AM12/15/15
to mezzanine-users
Hi Joel,

The calendar metaphor does not fit well into the Page model that ships with Mezzanine. Have you explored the Book and Author example in the Mezzanine documentation? It may provide some insight on how to approach this problem The Mezzanine Way.

-ken

Joel Gwynn

unread,
Dec 15, 2015, 12:14:39 PM12/15/15
to mezzani...@googlegroups.com
I have looked at that, but it seems that to handle form input and url parameters I would still have to create a page_processor method, no?

--
You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/CsWdyQS9M64/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.

Eduardo Rivas

unread,
Dec 15, 2015, 12:19:01 PM12/15/15
to mezzani...@googlegroups.com
I think the Blog app would also be a good place to look.

Basically, what you want to do is outside the scope of Pages and page
processors. You'd be better off implementing the calendar as a regular
Django app (you can still use Mezzanine's Displayable class, though)
with it's own url patterns, models and views.

You can then create a Page instance with the same slug as the url where
you have mounted your app (as Mezzanine does with the Blog) to have it
show up in the navigation menu. The Page instance will also be available
to all elements mounted under the same url prefix in your app.

https://github.com/stephenmcd/mezzanine/tree/master/mezzanine/blog

Eduardo Rivas

unread,
Dec 15, 2015, 12:22:13 PM12/15/15
to mezzani...@googlegroups.com
This section of the docs expands a little on my previous message:
http://mezzanine.jupo.org/docs/content-architecture.html#integrating-third-party-apps-with-pages

Joel Gwynn

unread,
Dec 20, 2015, 12:09:22 PM12/20/15
to Mezzanine Users
Just to close this out: what I ended up doing was creating a simple view and handling the url parameters there:

def calendar(request, slug, template=u"pages/page.html", extra_context=None):

# do my url parsing here and set page parameters

return mezzanine.pages.views.page(request, "calendar", template, extra_context)

Thanks for the suggestions!
Reply all
Reply to author
Forward
0 new messages