django(未解决的问题)

1. can't compare datetime.datetime and datetime.date

 

2.Django手册1.4中提到TEMPLATE_DIRS = ( '/home/project/mysite/templates/' )使用这种方法加载模板路径

这是手册中的一个函数def index(request):

    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
    t = loader.get_template('polls/index.html')
    c = Context({
        'latest_poll_list': latest_poll_list,
    })
    return HttpResponse(t.render(c))

最终运行的时候报错 提示模板不存在,无法解决。
最后还是按照vamei的做法:
TEMPLATE_DIRS = (
   os.path.join(BASE_DIR, 'templates/polls/')
)
才未报错,谁知道为什么么?????

3.    <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>,在红色处/和{之间有空格也会报错(url不匹配)



 

posted @ 2017-03-29 23:19  hpuzhong  阅读(145)  评论(0编辑  收藏  举报