I thought that something like that was the answer. Normally I would agree but I can't think of another way to make a calendar style layout with certain events on it. Check out my glorious hack and tell me what you think.
c is a matrix from the calendar object. import calendar calendar.setfirstweekday(calendar.SUNDAY) c = calendar.monthcalendar(2007, 6) output = [] for w in c: output.append('<tr>') for d in w: output.append('<td>') output.append('<p>') if d: output.append(str(d)) else: output.append(' ') output.append('</p>') output.append('<div>') if d in attendance and attendance[d] > 0: output.append(str(attendance[d])) else: output.append(' ') output.append('</div>') output.append('</td>') output.append('</tr>') output = ''.join(output) Somehow I doubt this should really be in the view either. Maybe it's just one of those out liers that doesn't have a good place. On Jun 7, 10:38 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 6/7/07, Trey <[EMAIL PROTECTED]> wrote: > > > > > The first line, dict.1 works fine. But when I try to use the d > > variable for the dict index it doesn't work. Is there a way to > > accomplish this? > > No, by design. We have explicitly tried to avoid making the django > template language a programming language. > > In the Django philosophy, it is the responsibility of the view author > to extract and order data; the template is then responsible for > displaying data, but not performing any calculations upon it. This is > done to maintain a clear separation between logic and presentation. > > Indexing arrays by another variable is a very programmatic construct - > hence its omission from the template language. If you feel the need to > do this, you should probably be looking at why your template needs > such complex logic, and why your view doesn't have that logic instead. > > Yours, > Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---