from {% for key in form.errors.keys %}, key is the (k,v) for
form.errors dictionary.
key={{key}} shows what the key contains. In this case, it is something
like "__all__"
According to the dot notation, I should be able to use form.errors.key
to access the array of error messages associated since the dot
notation translate to dictionary look up first.
So I think form.errors.key = forms.errors['__all__'] in this case.
Anyone know why not?
On Jun 8, 11:21 pm, Rama Vadakattu <[email protected]> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---