【问题标题】:Labels aren't showing before fields标签未显示在字段之前
【发布时间】:2012-01-11 06:41:32
【问题描述】:

这个sn-p来自forms.py:

class TestForm(forms.Form):
    Specialist = forms.ModelChoiceField(label = 'Test', queryset = SpecialistModel.objects.all(), empty_label = None)

这个来自模板:

{{ form.Specialist }}

字段显示,标签未显示。问题可能出在哪里?

【问题讨论】:

    标签: django django-forms django-templates


    【解决方案1】:

    您必须手动显示标签:

    {{ form.Specialist.label }}
    

    {{ form.Specialist.label_tag }}
    

    显示包装在 html <label></label> 标签中的标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-26
      • 2016-05-27
      相关资源
      最近更新 更多