So what is your problem? update_cal_links() doesn't work after page refresh?
On Apr 20, 1:05 pm, Tonne <pascal.bomp...@gmail.com> wrote: > > I didn't see how you return array to template context. > > Okay... well, it's actually a string that I finally send to the > template. It's a long story (sorry), but I use the array to build a > string (i.e values from the array get embedded in HTML source). The > place where the string is return to the template is the last line on > the tag, i.e. "return home_calendar". > > The line above it "home_calendar = print_cal()", shows how > print_calendar is a value derived from the function that builds the > string. > > I could show you the source of the array and string building function, > but I'm afraid you eyes might bleed :) > > On Apr 20, 4:37 pm, Anatoliy <anatoliy.la...@gmail.com> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---