Answer the question
In order to leave comments, you need to log in
Why doesn't get_context_data() work with get()?
I have overridden the get_context_data method in my ListView :
def get_context_data(self, **kwargs):
context = super(GoodsList, self).get_context_data(**kwargs)
context['some_context'] = 'Some context'
return context
This way I get the context in my template. But if I want to process the request in the same class with the get() method, then the context is no longer passed to the template, and calling the get_context_data() method in the get() method throws an exception:object has no attribute 'object_list'.
Answer the question
In order to leave comments, you need to log in
You need to look at the inheritance hierarchy of CBV and mixins, understand the order of calling methods, and the question will disappear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question