Django get context data across Views
<p>I know that there are several generic views like <code>ListView</code>, <code>DetailView</code>, or simply <code>View</code>.
The thing is can I actually get the context data that are declared in a <code>BaseMixin</code>'s <code>get_context_data()</code> and use it in a View that doesn't have override <code>get_context_data()</code>?
Example:</p>

<pre><code> class BaseMixin(object):
    def get_context_data(self, *args, **kwargs):
        context = super(BaseMixin, self).get_context_data(**kwargs)
        context['test'] = 1
        return context
</code></pre>

<p>And the view that extends this <code>BaseMixin</code>:</p>

<pre><code>class FooView(BaseMixin, View):
    def foo(self, request):
        context = super(BaseMixin, self).get_context_data(**kwargs)
        # do something 
       return
</code></pre>

<p>This is not working actually, even after put <code>**kwargs</code> as a parameter in <code>foo()</code>. The error is <code>'super' object has no attribute 'get_context_data'</code>.
So is there a way to get context data which was set in <code>BaseMixin</code> in <code>FooView</code> ?</p>

<p>Thanks for your answers :)</p>

<p>Thanks to @Sayes and all answer posters, I finally solved this problem.
From what I figured out, the problem is actually in <code>BaseMixin</code>, the inherited class of <code>BaseMixin</code>, which is <code>object</code>, doesn't have a <code>get_context_data()</code> function, just like @Sayes commented.
After replace this <code>object</code> with <code>ContextMixin</code>, everything works perfectly, at least perfectly for now.</p>

<p>Here is the modified <code>BaseMixin</code>:</p>

<pre><code>class BaseMixin(ContextMixin):
    def get_context_data(self, *args, **kwargs):
        # do something
        return context
</code></pre>

python django python-3.x