On 2/12/06, Luke Plant <[EMAIL PROTECTED]> wrote:

On Saturday 11 February 2006 22:00, Roberto Aguilar wrote:

> I've noticed that in certain instances, in a flatpage, for example,
> the user context variable is available in my templates.  However,
> most of the time I have to explicity provide it like when using
> render_to_response.  Is this a bug, feature, or am I just not doing
> something right?

The 'user' context variable is provided by 'DjangoContext' (more
specifically, by one of the 'processors' that DjangoContext uses:
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext )

DjangoContext is used by all the generic views (including flatpage). If
you want it in your own views, just use DjangoContext instead of
Context, passing the 'request' object into the DjangoContext
constructor.

Or if you are using render_to_response/string shortcuts, use something like:
render_to_response('template', context_instance=DjangoContext(request))

--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701

Reply via email to