У меня есть форма, которую я хочу сделать хрустящей,
ФОРМА
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
excludes = ('user', 'created')
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_show_labels = False ## I only need the input field
self.helper.layout = layout.Layout(
layout.Field('name', css_class="form-control"),
layout.Field('objective', css_class="form-control"),
## ADD CLASS form-control TO THE FIELDS (This is the problem since the fields are not rendered with the class)
)
super(MyForm, self).__init__(*args, **kwargs)
ШАБЛОН
<div class="form-group">
<label>Name <i class="fa fa-question-circle tooltips" data-original-title="Lorem Ipsum" data-html="true" data-placement="right" data-container="body"></i></label>
{{ form.name|as_crispy_field }}
{{ form.name.errors|striptags }}
</div>
<div class="form-group">
<label>Theme/ Objective <i class="fa fa-question-circle tooltips" data-original-title="Lorem Ipsum" data-html="true" data-placement="right" data-container="body"></i></label>
{{ form.objective|as_crispy_field }}
{{ form.objective.errors|striptags }}
</div>
Поля не отображаются с классом form-control
. Метки отображаются, и они мне не нужны, так как у меня есть свои собственные метки. Любая помощь в том, как я могу отображать поля с классом, будет высоко оценена. Спасибо.
crispy-forms
и отобразить форму вручную docs.djangoproject .com/en/1.7/topics/forms/ - person Selcuk   schedule 13.02.2015