1👍
The parameters you pass to as_view
are assigned as instance variables on your class based view so you can can self.template
, i.e:
...
return render(request, self.template, {...})
As a sidenote, if you were using a named url patterns that captured a slug, for example:
url(r'^about/(?P<slug>[\w-]+)/$', foo.as_views(template='about.html')),
you would have access to the slug
variable that is passed via the url by using the kwargs
instance variable:
self.kwargs['slug']
Source:stackexchange.com