开发者

Django class based generic views: cannot import name TemplateView

开发者 https://www.devze.com 2023-01-31 00:37 出处:网络
Dj开发者_Python百科ango fires exception cannot import name TemplateView how to fix this? view.py :

Dj开发者_Python百科ango fires exception cannot import name TemplateView how to fix this?

view.py :

from django.views.generic import TemplateView

class Monitor(TemplateView):
    template_name  = 'helo.html'


urls.py :

from monitor.views import Monitor

urlpatterns = patterns('',
    (r'^admin/', Monitor.as_view()),
)


I don't know what Django version you are using, but only in Django 1.3 a class called TemplateView exists. Its import should be:

from django.views.generic.base import TemplateView
0

精彩评论

暂无评论...
验证码 换一张
取 消