Django: request object to template context transparancy

Posted by anars on Stack Overflow See other posts from Stack Overflow or by anars
Published on 2010-03-23T09:06:15Z Indexed on 2010/03/23 10:13 UTC
Read the original article Hit count: 220

Filed under:
|
|
|
|

Hi!

I want to include an initialized data structure in my request object, making it accessible in the context object from my templates. What I'm doing right now is passing it manually and tiresome within all my views:

render_to_response(...., ( {'menu': RequestContext(request)}))

The request object contains the key,value pair which is injected using a custom context processor. While this works, I had hoped there was a more generic way of passing selected parts of the request object to the template context. I've tried passing it by generic views, but as it turns out the request object isn't instantiated when parsing the urlpatterns list.

© Stack Overflow or respective owner

Related posts about python

Related posts about django