crispy-forms: add css class for one of the inputs

前端 未结 6 941
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-17 14:48

In my forms.py I have

[...]
self.helper.layout = Layout(
    Field(\'name\'),
    Field(\'description\'),
)
self.helper.form_class = \'form-hori         


        
6条回答
  •  情歌与酒
    2020-12-17 15:48

    I see two possibilities:

    1. Use CSS

    #div_id_name {
        font-weight: 0.8em;
    }
    

    2. Override the field template

    You can override the field template of your field:

    Field('field_name', template='my_field_template.html')
    

    For a reference field template, see site-packages/crispy_forms/templates/bootstrap3/field.html.

    (3. Waiting)

    There's an open issue on Github for this: https://github.com/maraujop/django-crispy-forms/issues/348

提交回复
热议问题