I get this error
TypeError at /debate/1/
get_context_data() takes exactly 2 arguments (1 given)
Right now it is defined as:
def get_context_data(self, **kwargs):
And I want it to be:
def get_context_data(self, request, **kwargs):
so I can do inside:
sort_by = request.GET.get('sort', '-rating_score')
Is this a good idea, and how to do it?
Request object is available as member of a Class Based View object and can be accessed by
self.request. If, for some reason, you do pass it in**kwargsusekwargs.get("request")since it’s a plain dict.