简体   繁体   中英

Multiline declaration in Python Django templates

Is it possible to use them? Something like

{% for long_variable_name in list %}
  {% declare %}
    bool_var = long_variable_name.sublist1.count > 0 and\
      long_variable_name.sublist2.count > 0
    ...

Similar question is about the {% if %}'s statements. Although as I understand, anyway it's better not to write complex boolean statements in them since if is very limited with operations and parentheses.

I came here with the same hope as you. According to this source there is no way to use multiline declarations in Django templates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM