C
C
Cyber_bober2016-03-18 11:45:40
Django
Cyber_bober, 2016-03-18 11:45:40

How to set labels and classes for form fields?

Hello, I'm submitting a form.

{% for field in user_form %}
            {{ field }}
            {% endfor %}

I want to add labels for the fields and give them custom classes, how can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-03-18
@Cyber_bober

{% for field in user_form %}
    <label class="class-name" for="{{ field.id_for_label }}">{{ field.label }}:</label>
    {{ field }}  
{% endfor %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question