如何添加一些HTML文本表单字段?这是我的forms.py:我的HTML文件的Django - 添加文本模型表单字段
class SiteAddFormFull(forms.ModelForm):
url = forms.URLField(widget=forms.TextInput(attrs={'readonly': 'readonly'}))
class Meta:
model = Site
fields = ('url', 'name', 'description', 'keywords', 'group', 'category',
'subcategory', 'category1', 'subcategory1', 'email')
def clean(self):
cleaned_data = super().clean()
subcategory = cleaned_data['subcategory']
subcategory1 = cleaned_data['subcategory1']
if subcategory1 and (subcategory == subcategory1):
raise forms.ValidationError("Subcategories can't be the same.")
部分:
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
{% bootstrap_form form_extended layout='horizontal'%}
{% bootstrap_button "Zatwierdź" size='large' button_type="submit" button_class="btn-primary" %}
</form>
我想以后 '组' 字段添加描述。喜欢的东西:
- 您可以到2个类别
- 您可以将网站加入网站2个小类
只是正常的HTML文本。我怎样才能做到这一点?
是否可以格式化(添加html标签)到help_text? – jundymek
如果你把它们包装在'mark_safe()'中,这可能是可能的。虽然我没有尝试过。 – Tim