How can I satisfy an import of direct_to_template?

a 夏天 提交于 2019-11-30 17:06:04

direct_to_template has been deprecated. In django 1.5 try using a Class based view in urls.py

from django.views.generic import TemplateView

urlpatterns = patterns('',
    url(r'^$', TemplateView.as_view(template_name='homepage.html'), name="home"),
)

There's some information on migrating to version 1.4 (when it was deprecated) here.

Besides the class-based view TemplateView, you can also use the render function like this:

from django.shortcuts import render

urlpatterns = patterns("",
    url(r'^$', lambda request: render(request, 'homepage.html'), name="home"),
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!