Template View - kwargs and **kwargs
<p>I am reading about Template views through a tutorial and some of the code kind of confused me. The author used this code sample</p>

<pre><code>from django.utils.timezone import now

class AboutUsView(TemplateView):
    template_name = 'about_us.html'

def get_context_data(self, **kwargs):
    context = super(AboutUsView, self).get_context_data(**kwargs)
    if now().weekday() &lt; 5 and 8 &lt; now().hour &lt; 18:
        context['open'] = True
    else:
        context['open'] = False
    return context
</code></pre>

<p>The thing that confused me syntactically was this statement</p>

<pre><code> context = super(AboutUsView, self).get_context_data(**kwargs)
</code></pre>

<p>if we already are receiving <code>**kwargs</code> then why are we passing it to the super function with ** (double start). I think we should pass it as </p>

<pre><code> context = super(AboutUsView, self).get_context_data(kwargs)
</code></pre>

<p>this is the contextMixin which is receiving this call.</p>

<pre><code>class ContextMixin(object):
    """
    A default context mixin that passes the keyword arguments received by
    get_context_data as the template context.
    """

    def get_context_data(self, **kwargs):
        if 'view' not in kwargs:
            kwargs['view'] = self
        return kwargs
</code></pre>

<p>From what I have read is that the use of <code>**kwargs</code> pretty much means that kwargs is currently a dictionary and needs to be converted to named-value. If that is correct then how can kwargs be a dictionary when its parameter is actually **kwargs. I hope my question makes sense. Please let me know if you would want me to rephrase this.</p>

<p>Here at your function definition, it is accepting multiple arguments, and parsing them into a dict. <code>def get_context_data(self, **kwargs):</code> </p>

<p>So now, kwargs is a dictionary object. So if you pass it to  <code>.get_context_data(kwargs)</code> it would have to expect only a single incoming argument, and treat it as a dictionary. </p>

<p>So when you do <code>**kwargs</code> a second time, you are blowing up the dictionary back into keyword arguments that will expand into that functions call.</p>

python django