Tonne, I didn't see how you return array to template context.
On Apr 20, 11:44 am, Tonne <pascal.bomp...@gmail.com> wrote: > Thanks > > > Can you show code of your tag and template where it used? > > Well, sure, but the tag is quite a big one, 150 lines long due to the > large array and string concatenation going on. So I've shown here only > what I assume to be the critical bits. > > (btw. the tag discussed here was the solution to this > issuehttp://groups.google.com/group/django-users/browse_thread/thread/ae40...) > > tag > ---------------------------------------------------------------------- > > cal = { 2007: > > { > 1: [ [1], [2], #etcetera....... a fairly big > multidimensional > array > > def update_cal_links(year, month, day): > """updates 'cal' array with a link to entry""" > link = "/%d/%d/%d/" %(year, month, day) > cal[year][month][day-1].insert(1,link) > return > > def print_cal(): > """ Returns a string, compiling calender into a series of nested > unordered lists""" > #I've removed the body of this function cos it's long, ugly > and it does seem to work fine > > @register.simple_tag > def do_home_calendar(): > """ Populates calendar with links to entries, > returns a formatted calendar to the template.""" > entries = Entry.objects.all() > for date in entries: > link = date.splitDate() #model method > update_cal_links(int(link['year']), int(link['month']), > int(link > ['day'])) # function expects integers > home_calendar = print_cal() > return home_calendar > > template > ---------------------------------------------------------------- > > {% extends "base.html" %} > {% load simple_tags %} > > {% block content %} > {% do_home_calendar %} > {% if archive_list %} > <h1>hello</h1> > <ul> > {% for entry in archive_list %} > <li><a href="{{ > entry.get_absolute_url }}">{{ entry.date }}</a></ > li> > {% endfor %} > </ul> > {% else %} > <h1>FAIL!</h1> > {% endif %} > {% endblock %} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---