Django class based generic views: cannot import name TemplateView
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
精彩评论