开发者

How do I check a field name from a Django form in html?

I have a Django form that contains several fields I am looping through. I want to branch the code if the field is the "comment" field, something like this:

{% for field in form.visible_fields %}
    {% if field == form.fields.comment %}
        <do something>
    {% else %}
        <do something else>
    {% endif %}
{% endfor %}

What i开发者_运维知识库s the correct syntax for the 2nd line? The current line always fails.


I believe it would be:

{% if field.field == form.fields.comment %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜