This is a Python question.  Python doesn't have "arrays", you are using 
lists.  Lists are indexed only by integers.  What you want is a 
dictionary, which can be indexed by any value.  Change your first line to:

    people = {}

and you should be all set.

--Ned.
http://nedbatchelder.com

Ted wrote:
> I want to take a table like People with entires id, Name, Sex and send
> it to HTML to do something like this:
>
> {% for name in people.filter(sex='M') %}
> <LI>Male: {{ People.Name }}
> {% end %}
>
> But, it's too late to do this in HTML.  So, I'm trying to create an
> array of pre-sorted lists in views.py to send to the HTML like this:
>
> people = []
> people['Men']=People.objects.filter(sex='M')
> people['Women']=People.objects.filter(sex='F')
> return render_to_response('people.html', {'people', people})
>
> But, I can't figure out how to initialize and populate the arrays in
> views.py properly.  What am I doing wrong?
>
> FYI, this is just an example.  My actual arrays are much larger which
> is why I can't just hard-code the two results.
>
> Thanks for any help you guys can provide.
>
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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