简体   繁体   中英

Compare entirely two different models in Django

I have been working in Django template. I have been stuck here since quite some time now.

{% for i in LOOP %}
    {% if i == {{SECOND VARIABLE}} %}
    //Do Something
{% endif %}
{% endfor %}

LOOP and second variable are entirely different. Is there something we can do? Is there some alternate solution

Inside {%if condition %} , condition is Python code (sort of). So, assuming SECOND_VARIABLE was passed in the context,

 {% for i in LOOP %}
    {% if i == SECOND VARIABLE %}

should work

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