【发布时间】:2021-05-29 22:25:59
【问题描述】:
我正在使用crispy 来呈现我的表单,但在呈现单个字段内联而不影响其他字段时遇到问题。
这个表格:
class SettingsUpdateForm(forms.ModelForm):
class Meta:
model = User
fields = ('about_text', 'github_name')
labels = {
'about_text': '',
'github_name': 'github.com/' # TODO make inline with field
}
widgets = {
'about_text': forms.Textarea(attrs={'placeholder': 'Describe yourself!????'}),
'github_name': forms.TextInput(attrs={'placeholder': 'your_github_name'})
}
help_texts = {
'github_name': 'Showcase a project instead: <em>/username/fav_project</em>',
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self) # this is required to display the help_texts
我希望github/ 标签与输入字段位于同一行。我该怎么做?
Horizontal Forms 将使所有标签成为引导网格模型的一部分 - 这是我不想要的。
我也尝试使用Inline Forms,但也没有用。
【问题讨论】:
标签: django django-crispy-forms