A
A
Astrohas2016-12-17 13:47:09
Django
Astrohas, 2016-12-17 13:47:09

How to use assignment in Django template engine?

I would like to use something like

{% if user.user.detail.lang = "eng" %}
eng = True
{% end if%}

how to do it?
UPD:
in general, there is only one reason - in templates it is often necessary to translate, and each time it is difficult to write {% if user.userdetail,lang == "eng %}, so I want all this like
{% if eng %}
Astalavista baby
{% endif %}

делать одно и тоже для каждой вюхи  как то нехочется

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tema_sun, 2016-12-17
@Astrohas

What for? There are also translation files and tags {% trans %}, {% blocktrans %}.
If you still want to have the eng variable in the templates, then make your own context processor.

S
sim3x, 2016-12-17
@sim3x

lang="{{user.user.detail.lang|default:'eng'}}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question