[Answer]-How do I get the value in my views? I am trying to use class based views

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']

Leave a comment