A
A
Alex Pavlichenko2017-05-09 11:45:39
css
Alex Pavlichenko, 2017-05-09 11:45:39

How to attach styles in a template to fields from a Django model?

There is such a form for registration, where form is the form of the model from django

<form action="" method="post">
                        {% csrf_token %}
                        {{ form.as_p }}
                        <div>
                            <input type="submit" class="btn" value="submit">
                        </div>
 </form>
как указать классы для этих полей, чтобы применить bootstrap стили

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-05-09
@lfr

class SomeForm(forms.Form):
    some_field = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question