0

我有一个下拉列表的 HTML 模板:

<select name="quality">
    {% for quality in qs %}
        {% ifequal qu.id sel.id %}
            <option value="{{sele.key}}" selected="selected">Movie {{qu.id}}: {{quality.name}}</option>
        {% else %}
            <option value="{{sele.keyy}}">Movie {{qu.id}}: {{quality.name}}</option>
        {% endifequal %}
    {% endfor %}
</select>

我如何在我的模型和视图中实现这一点,或者我如何为下拉列表编写模型和视图......

4

1 回答 1

1

Use django forms

They are great for reusing forms, validation, and make processing forms much more pythonic.

You can create a ChoiceField in your form, and then give a tuple showing [[value, label], [value, label], [value, label]]

于 2012-11-08T12:06:04.607 回答