you have to use the below code to print messages instead of keys

{% for key,message  in form.errors  %}
             {{ message|striptags  }}
{% endfor %}


On Jun 9, 11:21 am, Rama Vadakattu <rama.vadaka...@gmail.com> wrote:
> {% for message in form.errors.key %}
>       {{message|striptags}}
>  {% endfor %}
>
> The above will print keys instead of values as message is key not a
> value.............
>
> On Jun 9, 11:06 am, Tom <tom...@gmail.com> wrote:
>
> > Hi all,
>
> > Leveraging the default login view, I want to use my own login.html to
> > show all the errors in the login form:
>
> >   {% if form.errors %}
> >   <p>Login Failed. Please try again.</p>
> >   {% for key in form.errors.keys %}
> >     <p>
> >      key={{key}},value=
> >      {% for message in form.errors.key %}
> >      {{message|striptags}}
> >      {% endfor %}
> >     </p>
> >   {% endfor %}
> >   {% for msg in form.errors.values %}
> >     <p>
> >      Message={{msg|striptags}}
> >     </p>
> >   {% endfor %}
> >   {% endif %}
>
> > The above prints the following when the username and password combo is
> > incorrect:
> > """
> > Login Failed. Please try again.
>
> > key=__all__,value=
>
> > Message=Please enter a correct username and password. Note that both
> > fields are case-sensitive.
> > """
>
> > I do not understand why the block:
> >      {% for message in form.errors.key %}
> >      {{message|striptags}}
> >      {% endfor %}
> > is not printing out the messages associated with each dictionary key.
>
> > I can only use form.errors.values to print them out instead.
>
> > Regards,
> > Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to