django how to create TemplateView instance with code -
i have function view,and want create templateview instance in function,such as
def myview(request): #view =templateview(request) #view =templateview.as_view() #view =templateview.as_view()(request) return view
but,all of them wrong. how create view?
urls:
mysite/widget1/ mysite/widget2/ mysite/widget3/
views:
class basewidgettemplateview(templateview): pass class widget1view(basewidgettemplateview): pass class widget2view(basewidgettemplateview): pass class widget3view(basewidgettemplateview): pass
the request pass function view , pass templateview diffent object type request pass function is
module 'django.http.request
and request in templateview is
wsgirequest
again, class based views page on django docs:
(r'mysite/widget1/', widget1view.as_view()), (r'mysite/widget2/', widget2view.as_view()), (r'mysite/widget3/', widget2view.as_view()),
this need define in urls.py
file.
Comments
Post a Comment