我正在關注一個Django教程,並且我遇到了一個有關我的某個視圖的問題。當從Django中輸出的錯誤它告訴我看,有上線62錯誤:Django語法錯誤
yr = datetime.datetime(year, 1, 1) months = 12
這裏是整個視圖:
def year(request):
#http://site_name/year/
post_error = ""
year = int(year)
yr = datetime.datetime(year, 1, 1) months = 12
by_month = []
if Post.objects.filter(published__year=year).count():
if year == datetime.datetime.now().year:
months = datetime.datetime.now().month
for month in range(1, months+1):
by_month.append({datetime.datetime(year, month, 1):
Post.objects.filter(published__month=month).filter(published__year=year)})
elif year > datetime.datetime.now().year:
post_error = "It is not yet %d, try an earlier year." % year
else:
post_error = "There are not posts for %d." % year
return render_to_response('year.html', {'by_month':by_month, 'post_error':post_error,},)
請告訴我,如果你需要了信息,我沒有提供。謝謝! -Chris
非常感謝! –