Hulk
Hulk

Reputation: 34170

Django templates condition check

All,

Can t we do the following in templates

{% if subject.id == selected_id %}

and also cannot we assign variable like {{selected="selected"}}

Thank........

Upvotes: 1

Views: 3090

Answers (2)

Felix Kling
Felix Kling

Reputation: 816472

This comparison will work in Django 1.2. For 1.1 you have to use ifequal:

{% ifequal subject.id  selected_id %}

For variable assignment you can use with.

{% with selected as 'selected' %}

{% endwith %}

Don't hesitate to read the documentation, it doesn't hurt.

Upvotes: 4

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798726

Not as shown. Use the ifequal and with template tags instead.

Upvotes: 0

Related Questions