I'm banging my head up against a wall on something.

Pretty printed, here is the grant object that I created and am passing  
to my Django Template:

{    2L: {63L: [<Grant: This is third summary>, <Grant: First  
Summary>]},
      4L: {79L:[<Grant: Second Summary>]}

This object is an instance of a sub-classed dictionary:

     class GrantsDict(dict):
         program_areas = ()
         organizations = ()

     grants = GrantsDict()
     grants.program_areas = list((p.id, p) for p in  
ProgramArea.objects.all())
     grants.organizations = list((p.id, o) for o in  
Organization.objects.all())


I would then step through my data, creating lists of objects. The  
outer keys (2L, and 4L in the above grants object) are indexes to my  
program_areas. The inner dictionaries (from each program area are  
indexes for Organization.

So, the above pretty printed object is interpreted as:
     Program Area 2:
         Organization 63:
             * <Grant: This is third summary>
             * <Grant: First Summary>
     Program Area 4:
         Organization 79:
             * <Grant: Second Summary>

However, when I try to dynamically step through the templating  
language, I am unable to dynamically reference a particular area  
(grants[2L][63L] in regular Python syntax where 2 and 63 are  
dynamically created from variables) as demonstrated:


This template:

<h1>start</h1>
alpha: {{alpha}} <br />
beta: {{beta}} <br />
grants.2.63: {{grants.2.63}} <br />
grants.{{alpha}}.{{beta}}: {{grants.alpha.beta}} <br />
<h1/stop</h1>

Creates this response:

start
alpha: 2
beta: 63
grants.2.63: [<Grant: This is third summary>, <Grant: First Summary>]
grants.2.63:
stop

Notice that I can reference grants.2.63 through direct reference, but  
when trying to use the variables alpha=2, and beta=63, this lookup  
fails.

I'm beating my head up against the wall with this. Could anyone send  
me some guidance?


Thank you in advance,


Warmest Regards,



Glen Jarvis
--
415-680-3964
g...@glenjarvis.com
http://www.glenjarvis.com

"You must be the change you wish to see in the world." -M. Gandhi


--~--~---------~--~----~------------~-------~--~----~
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