On Tue, 2009-05-19 at 06:46 -0700, laspal wrote:
> Hi,
> My model is :
> id val msg
> 20 1234 text
> 20 1245 text
> 20 1275 text
> 20 1356 text
>
> so I have to display record in calendar format.
> I am doing it in this way:
> final_list =[]
> somelist = [1200, 1250, 1300, 1350, 1400]
> val = 0
> i = iter(range(5))
> testing_list =[]
> for item in i:
> user_status_list = UserStatus.objects.filter(id =20,time__gte
> = somelist[val], time__lte = somelist[val+1))
> for item in user_status_list:
> testing_list.append(item)
>
> final_list.append(testing_list)
>
> so my final list should look like:
>
> [ [ [20, 1234, sdfs], [20, 1245, sdffd] ], [ 20,1275, dfdfgf], [ ],
> [20, 1356, dsfdf] ]
>
> wanted to know How can I use this list in my template.
> for item in final_list:
> for val in item:
> print val.id, val.val, val.msg
>
> which is wrong.
> how can I fix this.
>
> thanks...
>
Build a dict instead, where you wish to refer to specific elements.
Eg:
foo = [ { 'id': 20, 'name': sdfs, }, { ..... } ]
and
{% for item in foo %}
{{ item.name }}
{% endfor %}
Cheers
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
-~----------~----~----~----~------~----~------~--~---