Hi.

You can use template context processors.

http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext

you can either use the built in processors or write your own. They
just have to be added in the settings file(all this is explained in
the docs)

These can provide you access to, ex. the current HTTPrequest in your
template… and therefore you would be able to write something like
{% if request.user.is_authenticated %}
welcome
{% else %}
login
{% endif %}

hope it helps :)

pete

On 26 Dec., 09:05, Igor Artamonov <igor.artamo...@gmail.com> wrote:
> Hi
>
> I need to make an custom tag, for auth checks, based on data stored on
> cookies. Like a:
> {% if_loggen_in %}
> <span>Some message for logged in only user</span>
> {% end_if_logged_in %}
>
> btw, i don't know how to get access to request object in my tag. I know that
> there is 'inclusion tags', but as you see there is nothing to include, my
> tag just renders data based on current request data.
>
> I know about .request middleware and RequestContext class, but this tag can
> be used anywhere (and at least it used in main layout, so it used in every
> page), so the way when I use RequestContext(context) in every possible view
> is too complex.
>
> How can i get access to it from custom tag? Can i make it use RequestContext
> by default?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to