Just put the condition inside the block.

On Mon, Apr 4, 2011 at 7:34 PM, Ethan Yandow <[email protected]> wrote:
> Hey Mr. Django! I am trying to have different information display in
> the same block depending on a variable "choice" which is simply an
> int. The way I was planning on doing so was going to be something like
> the bellow code:
>
> {% extends "index.html"%} {%block head%}
>
> Welcome to Piss && ink {{user}}
>
> {%endblock head%}
> {%block one%}
> The temperature in {{city}} is {{temperature}}&deg
>
> {%endblock one%} {%if choice1 == 2 %} {%block two%}
> The temperature in {{city}} is {{temperature}}&deg
>
> {%endblock two%} {% endif %} {%comment%}{%if choice1 == 2 %} {%block
> two%}
> The temperature in {{city}} is {{temperature}}&deg
>
> {%endblock%} {% endif %}{%endcomment%} {%block two%} {%csrf_token%} {%
> if new_event %}
> {{new_event}}
>
> {% endif %} {%endblock%}
> Now, the problem I am having is that the template doesn't like that
> there are two blocks of the same name in the template. For some reason
> it doesn't seem to care about the {%if%} statement that is checking
> where the {%block%} is supposed to go. I thought that the {%if%}
> statement would only execute what was inside itself depending on its
> parameters but it doesn't seem to be doing that. It displays
> everything inside the {%if%} no matter what "choice1" is equal too :
> ( Does anyone have any idea how I might be able to fix this? Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to [email protected].
> 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.
>
>



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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