I'm new to Django and I can't find anywhere which instance variables do class-based generic views have. For example, I know that you can use self.request or self.kwargs, but is there any list of which other variables can I use? Maybe I can set any variable I need in the dispatch function, but what are the defaults?
1 Answer
I agree that this is not documented as well as it could be.
The overview of class-based generic views says this:
Various useful things are stored on self; as well as the request (self.request) this includes the positional (self.args) and name-based (self.kwargs) arguments captured according to the URLconf.
Then, the reference documentation lists the attributes created for each specific view. Under DetailView, for example, it says:
While this view is executing, self.object will contain the object that the view is operating upon.
Another reference you might want to consult is Classy Class-Based Views.
as_view, see__init__method of theViewclass.