On Sep 17, 6:12 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 9/17/07, bramble <[EMAIL PROTECTED]> wrote:
>
> > My base.html has this:
>
> >     {% block greeting %}not logged in{% endblock %}
>
> Personally, I wouldn't use the view for this; I'd do
>
> {% if user.is_authenticated %}Hello, {{ user.username }}{% else %}Not
> logged in{% endif %}
>
> If you must assign the "greeting" variable in views, I'd do it like so:
>
> {% if greeting %}{{ greeting }}{% else %}Not logged in{% endif %}
> (this way, if the "greeting" variable is not set, you get what you
> want

Ok. I get it. The variables you set in your view are global to all
levels of the template inheritance hierarchy.

> -- you could also put "{{ block.super }}" in place of the "Not
> logged in" text)

Ah. That gets what the parent template had {% block foo %}right here{%
endblock %}. Nice.

I also now see that the Django "templates" documentation points me to
my webapps Admin "Documentation" link which has a tags reference as
well.

Thanks again.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to