choice_value缺少django

时间:2017-04-06 04:07:21

标签: python django python-3.x

这是我的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>

正如您所看到的那样,缺少价值标签,那么我应该写些什么才能使其发挥作用?

0 个答案:

没有答案