﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20219	block evaluation preceeds if-statement evaluation	djangobug@…	nobody	"I have a login page on my website that extends the base template. I a user is already logged in and visits the login page again, I want to show a notice saying that the user is already logged in.

The base.html template contains a 
{{{
{%block meta%}{%endblock%}
}}}
placeholder in the head of the html document.

In the login page I added:
{{{
{%extends ""base.html""%}
{%if user and user.is_authenticated%}
  {%block meta%}
    <meta http-equiv=""refresh"" content=""0;url=/"">
  {%endblock%}

  {%block content%}
  You are already logged in, etc.
  {%endblock%}
{%else%}
  show the login form, etc
{%endif%}
}}}

The problem is that even when I'm not logged in, the meta-tag is still inserted in the html page. This causes the login form to be refreshed continuously, making it impossible to log in.

I have found a workaround: In the base template I placed an is_authenticated check around the meta block:
{{{
{%if user.is_authenticated%}
  {%block meta%}{%endblock%}
{%else%}
  {%block meta_unauth%}{%endblock%}
{%endif%}
}}}

This prevents the meta-tag from being placed on the page when the user is not authenticated (the meta block does not exist then).

It seems to me that the evaluation of the block- and if-statements is not in the correct order in the template, but it is in the correct order in the base.html template."	Bug	closed	Template system	1.4	Normal	wontfix			Unreviewed	0	0	0	0	0	0
