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

2013-08-26 Thread Daviddd
I solved in this way: my_dict = collections.defaultdict(lambda: collections.defaultdict(list)) for obj in queryset: my_dict[int(obj.position.split('-')[0])][int(obj.position.split('-')[2])].append(obj) for obj in my_dict: my_dict[obj].default_factory = No

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

2013-08-26 Thread Daviddd
On Friday, August 23, 2013 5:58:38 PM UTC+2, Daviddd wrote: > > Dear All, > > In my view I create the following dictionary of lists from a queryset > > #view.py > queryset = MyModel.objects.filter(owner=user, > dashboard=tab).order_by('position') > my_dict = collections.defaultdict(lambda: colle

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

2013-08-26 Thread Thomas Scrace
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 a

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

2013-08-25 Thread Daviddd
Thanks Tom for replying! The code used to create the dict is: my_dict = collections.defaultdict(lambda: collections.defaultdict(list)) for obj in queryset: my_dict[int(obj.position.split('-')[0])][int(obj.position.split('-')[2])].append(obj) Basically I have one field in the queryset calle

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

2013-08-24 Thread Thomas Scrace
On 23 Aug 2013, at 16:58, Daviddd wrote: > In my template I tried: > > {% for key, groups in queryset.iteritems %} > groups = {{ groups }} > {% for group_key, cols in groups.iteritems %} > cols = {{ group_key }} > {% for objs in cols %} > {# rest of the code #} >

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

2013-08-23 Thread Daviddd
Dear All, In my view I create the following dictionary of lists from a queryset #view.py queryset = MyModel.objects.filter(owner=user, dashboard=tab).order_by('position') my_dict = collections.defaultdict(lambda: collections.defaultdict(list))for obj in queryset: my_dict[int(obj.positi