Hello! I have hit a small road block in designing a fairly simple CMS
application:
My url pattern is:
url(r'^(?P<url>[A-Za-z-_//]+)/$', page_handler, name='page_handler')
I'm capturing whatever URL handing it off to a page handler view
function that matches up a Page by slug and returns it .. this works
great for textual content.
View:
def page_handler(request, url=None):
#Default to page root when no url
if url == None:
page = get_object_or_404(Page, id=1)
else:
page = get_object_or_404(Page, slug__exact=url)
if not page.template:
template = 'cms/default.html'
else:
template = page.template
return render_to_response(template, {
'page': page,
'request': request,
})
I am trying to figure out if there is a way to pass additional context
to a template from the view, say I have made a contact page but this
page needs to access a form, currently I don't know how I would be
able to do that, that is, to pass the form context to whatever
template the Page specifies. Normally I'd just map a URL to a
"contact" view function that handles the form and passes it off to a
template. I am trying to be efficient about this without "hard-coding"
that in ... if that makes sense.
Any help is appreciated!
Regards, Titus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---