Hi there.

I'm trying to create a list of days of the upcoming week in my template. I have the following, but would like to have the template instead utilise a for loop instead of hard coding the days.
At present i have the following - which works:

#views.py

def detail(request):
    date_list={'0':datetime.date.today(),
               '1':datetime.date.today()+datetime.timedelta(days=1),
               '2':datetime.date.today()+datetime.timedelta(days=2),
               '3':datetime.date.today()+datetime.timedelta(days=3),
               '4':datetime.date.today()+datetime.timedelta(days=4),
               '5':datetime.date.today()+datetime.timedelta(days=5),
               '6':datetime.date.today()+datetime.timedelta(days=6)}
return render_to_response('Main/template.html', {'Date_List': date_list})

#template.html

<h4>{{ Date_List.0 }}</h4>
<h4>{{ Date_List.1 }}</h4>
<h4>{{ Date_List.2 }}</h4>
<h4>{{ Date_List.3 }}</h4>
<h4>{{ Date_List.4 }}</h4>
<h4>{{ Date_List.5 }}</h4>
<h4>{{ Date_List.6 }}</h4>

I imagined replacing it with something like:

{% for date in Date_List %}

<h4>{{ Date_List.NotSureWhatToPutHere }}</h4>

{% endfor %}

But I don't know what to put there. I originally thought ".forloop.counter0" but that doesn't work.

Any ideas on how to go about this?

Cheers

Mark

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

Reply via email to