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