S
S
Sergey Nizhny Novgorod2016-01-12 05:44:51
Django
Sergey Nizhny Novgorod, 2016-01-12 05:44:51

How to edit css styles in forms in Django?

Guys, hello everyone.
Now I am connecting forms on Djange to my site (generating them based on the model). The question is, how to set css for the form? Something I somehow did not quite understand.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Z
zelsky, 2016-01-12
@zelsky

17a6641a94764cbf98b19fe6ff60b92d.png

<div class="input-field col-md-12">
          <div class="row">
            {{ form.username }}
            <label for="nick_name">Нікнейм</label>
          </div>
        </div>
        <div class="input-field col-md-6">
          {{ form.first_name }}
          <label for="first_name">Ім’я</label>
        </div>
        <div class="input-field col-md-6">
          {{ form.last_name }}
          <label for="last_name">Прізвище</label>
        </div>

A
Andrey K, 2016-01-12
@mututunus

I recommend https://github.com/kmike/django-widget-tweaks

T
TheML9I, 2016-01-12
@khaletskiy

https://github.com/kmike/django-widget-tweaks
or as an option in the form:

self.fields['field_name'].widget.attrs['class'] = 'your_class'

S
sim3x, 2016-01-12
@sim3x

If you are too lazy to do something, then it's better like this
https://github.com/tzangms/django-bootstrap-form
https://github.com/viewflow/django-material

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question