Monday, August 26, 2013

Re: django template loop collections.defaultdict(lambda: collections.defaultdict(list))

On Monday, 26 August 2013, Daviddd wrote:
Sincerely, I don't know how I can create the dict without using defaultdict.

D

You can create it using a defaultdict if you want to, but once it is created, and before you pass it to the template, loop through all the values of your outer dict and coerce them to dicts using dict(). You are already doing this for your outer defaultdict, which is why the first loop works in your template.

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment