On 12/21/05, Colleen Owens <[EMAIL PROTECTED]> wrote:
I'm a Django newbie. This follows up on a question I asked before and a very helpful answer to on this list.
So I have a list of dates and for each date I have a list of link objects I want to display. I'm trying to figure out how to best pass this data from my view to the template.
I tried this and several variations on this, but I'm not properly accessing the variable keys that I'm passing into my Context object. I guess what I really don't understand is what can be passed into the template and how it's accessed. All the examples I could find just pass in very simple lists.
def index(request):
date_list = newslists.get_list(order_by=["-date"])
args = {'date_list': date_list}
for date in date_list:
dateids = date.get_link_order()
datelinks = []
for id in dateids:
datelinks.append(links.get_object(id__exact = id))
args[] = datelinks
t = loader.get_template('news/index')
c = Context(args)
return HttpResponse(t.render(c))
(nevermind that even if this worked, the list wouldn't be very pretty)
<ul>
{% for date in date_list %}
<li>{{ date }}</li>
{% for link in date %}
<li>{{ link.title }}</li>
{% endfor %}
{% endfor %}
</ul>
Thanks for your help!
Colleen