这是我的form
:
class SimpleSearchForm(forms.Form):
options = [(obj.id, obj.name) for obj in Skill2.objects.filter(category="massage")]
skills = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple(attrs={"name": "select_0", "class": "full_search_checkbox"}),
choices=options)
这是我的template.html
:
{% for skill in simple_search_form.skills %}
<input type="checkbox" name="skills" value="{{ skill.choice_value }}"
{% if skill.choice_value in params.full_params %}checked{% endif %}/>
<label> {{ skill.choice_label }}}</label>
{% endfor %}
它在localhost
上工作正常,我得到了html
:
<input type="checkbox" name="skills" value="some_value">
<label>some_text</label>
但在生产服务器上(我部署到pythonanywhere.com
)
我得到以下html输出:
<input type="checkbox" name="skills" value">
<label>some_text</label>
正如您所看到的那样,缺少价值标签,那么我应该写些什么才能使其发挥作用?