Form help_text and error list styling

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Form help_text and error list styling

Ruchit Bhatt
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) ?

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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 | Threaded
Open this post in threaded view
|

Re: Form help_text and error list styling

SHAILESH NEGI
Try django message framework

On Jan 12, 2018 10:38, "Ruchit Bhatt" <[hidden email]> wrote:
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) ?

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/CAEFKsYPVind1i-aBuUm99A-Wt%2Bkt29C18YdKdG9McrVu4Ydq1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.