I’m just getting my hands dirty with class-based views.
What is the correct way to pass default values for optional parameters to my class-based view?
for example I was previously pretty much doing this:
http://lethain.com/using-optional-parameters-in-django-urls/
Now I’m not so sure how to achieve the same effect in class based views. i.e. how do I define the class in the view, what should the entry in urls.py look like and how do I define default values for the optional parameters?
The url arguments are stored in
self.argsandself.kwargs. There are some examples in the dynamic filtering section of the generic class based views docs.You could pass default arguments by including extra options in your url pattern, or just set a default in your view when you fetch the value from
self.kwargs.