help_text-Django Crispy表单
我想在表单中添加帮助文本:help_text-Django Crispy表单,django,forms,django-crispy-forms,Django,Forms,Django Crispy Forms,我想在表单中添加帮助文本: investigation_title = forms.CharField( error_messages={'required': 'Please provide an Investigation Title'}, help_text = 'Help text...', ) def __init__(self, *args, **kwargs): super(InvestigationForm, self).__init__(*args,
investigation_title = forms.CharField(
error_messages={'required': 'Please provide an Investigation Title'},
help_text = 'Help text...',
)
def __init__(self, *args, **kwargs):
super(InvestigationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = True
self.helper.form_class = 'form-horizontal'
...
self.helper.help_text_inline = True
...
但与此类似,帮助文本呈现在字段框下方。如何将帮助文本移动到字段框的右侧,位置如红色矩形中的图片所示
模板:
<div class="card-body">
<form method="post" class="form" novalidate="novalidate">
{% crispy form %}
</form>
</div>
{%crispy form%}
您是否设置了self.helper.error\u text\u inline=True
?还显示模板中渲染表单的部分否我没有设置self.helper.error\u text\u inline=True。我会看一下脆表文档,看看它有什么作用。我用表单呈现的模板更新了问题。感谢您的关注。error\u text\u inline
和help\u text\u inline
是helper类上的属性,设置其中一个会取消另一个属性的设置,因此一次只能有一个属性为True
,这就是我在评论中要求的原因。感谢您的澄清!