我为它写了一个 index.html 和一个 views.py。我得到日期并将月份数据转换为口头数据,如下所示。它适用于索引页面,但是当我从其他页面扩展索引页面时,日期不会到来。
def index(request):
datenow = date.today()
datemonth = date.today().month
if datemonth == 8:
date_month="Ağustos"
elif datemonth == 9:
date_month = "Eylül"
elif datemonth == 10:
date_month = "Ekim"
elif datemonth == 11:
date_month ="Kasım"
elif datemonth == 12:
date_month ="Aralık"
elif datemonth == 1:
date_month ="Ocak"
elif datemonth == 2:
date_month ="Şubat"
elif datemonth == 3:
date_month ="Mart"
elif datemonth == 4:
date_month ="Nisan"
elif datemonth == 5:
date_month ="Mayıs"
elif datemonth == 6:
date_month ="Haziran"
elif datemonth == 7:
date_month ="Temmuz"
news = New.objects.all()[:10]
programs= Program.objects.filter(date=date.today())
print date.today()
print date_month
template = "index.html"
context = {'news':news,
'programs':programs,
'datenow':datenow,
'date_month':date_month}
return render_to_response(template,context,context_instance=RequestContext(request))