I'm trying to create a page for mass user creation, and I'm having
troubles iterating over the error dictionaries in the template. The
dictionary I am trying to iterate over looks like this:

{'username': [u'User with this Username already exists.']}

But rather than iterating over this single item, the for loop in the
template jumps right to the {% empty %} tag, despite the dictionary
clearly having items in it.

Here's what is in the view:

 46                     try:
 47                         u.full_clean()
 48                         u.save()
 49                     except ValidationError, e:
 50                         unsaved_users.append([u,e])

Where u is a User object

Here's what is in the template:

 9 {% for user, errors in unsaved_users %}
 10 {{ user }} was not saved:
 11     <ul>
 12         {% for key,value in errors.items %}
 13             <li>{{ key }}: {{ value }}</li>
 14         {% empty %}
 15             <li>Django thinks I'm empty...</li>
 16         {% endfor %}
 17     </ul>
 18 {% endfor %}

Any idea what's going on here? The only thing I can come up with is
that the template language can't handle nested search of a list and
then a dictionary.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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