简体   繁体   English

Django模板从表单中排除字段

[英]Django templates exclude field from form

I'm working with django-bootstrap4 . 我正在使用django-bootstrap4 I want to exclude one field from form. 我想从表单中排除一个字段。 How can I do that with bootstrap4 . 我如何用bootstrap4做到这一点。

my view: 我的观点:

{% for item in form %}
        {% cycle 'row' '' as row silent %}
        {% if row %}
        <div class="row">{% endif %}
            <div class="col-md-6">
                {% bootstrap_field item exclude=item.insured_type %}
            </div>
            {% if not row %}
        </div>
        {% endif %}
{% endfor %}

I read the documentation and bootstrap_field have exclude parameter but I have no idea how to use that. 我阅读了文档, bootstrap_field具有exclude参数,但是我不知道如何使用它。 I wanted to exclude field that name insured_type . 我想exclude名称为insured_type字段。

很简单。

{% bootstrap_field item exclude="insured_type" form_group_class="col-md-6 form-group" %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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