django旁边的子弹多个MultipleChoiceField

时间:2014-01-21 23:38:39

标签: django django-forms

我有一个带有2个MultipleChoiceField的表单和CheckboxSelectMultiple小部件。

在模板中渲染时,复选框在每个选项的左侧都有一个“项目符号点”。

我认为它与复制品有关,但我不知道如何删除要点?

非常感谢您的反馈。

表格

class GameScheduleForm(forms.Form):

    weight_training_days = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
        choices=(
            (0, "MONDAY"),
            (1, "TUESDAY"),
            (2, "WEDNESDAY"),
            (3, "THURSDAY"),
            (4, "FRIDAY"),
            (5, "SATURDAY"),
            (6, "SUNDAY"),
        ),
    )

    cardio_training_days = forms.ChoiceField(widget=forms.CheckboxSelectMultiple,
        choices=(
            (0, "MONDAY"),
            (1, "TUESDAY"),
            (2, "WEDNESDAY"),
            (3, "THURSDAY"),
            (4, "FRIDAY"),
            (5, "SATURDAY"),
            (6, "SUNDAY"),
        ),
    )

模板

{% extends "fitgames/fitgames_base.html" %}

{% block content %}
<div class="row-fluid">
    <div class="well game span4 offset4">
        <div class="row-fluid">
            <h4 class="text-center">Total Body HIT</h4>
            <p class="text-center">Select the days you can workout</p>
        </div>
        <div class="row-fluid">
            <form method="post" action="{% url 'game_setup2_schedule' %}"> {% csrf_token %}
                <div><strong>Select 3 Weight Training Days</strong></div>
                <div>{{ form.weight_training_days}}</div>
                <div><strong>Select 3 Cardio Days</strong></div>
                <div>{{ form.cardio_training_days }}</div>
                <div><button class="btn btn-primary btn-large" type="submit">&nbsp;Next</button></div>
            </form>
        </div>
    </div>
</div>

{%endblock%}

2 个答案:

答案 0 :(得分:5)

当forms.CheckboxSelectMultiple被渲染时,它将以ul标记呈现。您需要做的是将以下内容添加到您的css中(根据需要使其更具体到该表单):

ul
{
    list-style-type: none;
}

答案 1 :(得分:2)

这会在不添加css的情况下删除项目符号点。 :)

{% for checkbox in form.Context %}
<div class="checkbox">
    <label>
            {{ checkbox.tag }} {{ checkbox.choice_label }}
    </label>
</div>
{% endfor %}