Form help_text and error list styling

10 views
Skip to first unread message

Ruchit Bhatt

unread,
Jan 12, 2018, 12:07:54 AM1/12/18
to Django users
Hi
I have made form for signup using Django 2.0 as below

            <form action="" method="POST"> {% csrf_token %}
                {% for non_field_error in form.non_field.errors %}
                   
<p> {{ non_field_error }} </p>
                {% endfor %}
                    {% for field in form %}
                        {{ field }}
                        {% if field.help_text %}
                            {% autoescape off %}
                           
<p> {{ field.help_text }} </p>
                            {% endautoescape %}
                        {% endif %}
                        {% for error in field.errors %}
                        {% autoescape off %}
                       
<p> {{ error }} </p>
                        {% endautoescape %}
                        {% endfor %}
                    {% endfor %}
                   
<input type="submit" id="submitBtn" value="SIGN UP"/>

Now i want to know how can i style error list and help text using css (which can work in all device) ?
And is it good practice to render each and every input field, errors & help separately (one by one using for loop) ?

 

SHAILESH NEGI

unread,
Jan 12, 2018, 12:10:44 AM1/12/18
to django...@googlegroups.com
Try django message framework

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93706232-0298-4b16-98b7-723986f0c777%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages