title: Django how to extend generic View class
body: <p>I noticed that I am setting site-wide context variables and request variables for many views on my site.  Naturally, this situation calls for inheritance.  If all of my view class-based views are inheriting from SiteView instead of the generic View, I can factor out all the commonalities into the SiteView child class. I can then inherit from SiteView on all my views.  But, I cannot get this to work.  Here is my code:</p>
  
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.views.generic import View
  from django.utils.decorators import method_decorator
  
  class SiteView(View):
      ''' Extends the generic django-supplied View class '''
  
      @method_decorator(login_required)
      def dispatch(self, request, *args, **kwargs):
           return super(SiteView, self).dispatch(*args, **kwargs)
  
      def get(self, *args, **kwargs):
          ''' Adds the variables required in the get request '''
          context = super(SiteView, self).get(*args, **kwargs)
  
          context['common_var'] = 'some common value'
          context['user'] = request.user
  
          return self.render_to_response(context)
  </code></pre>
  
  <p>This throws the following TypeError:</p>
  
  <pre><code>    dispatch() missing 1 required positional argument: 'request'
  </code></pre>
  
  <p>Any help would be appreciated</p>
  
  <p>Edit:  Even though the correct answer is marked, there were other issues with the code. In particular, the get method of the SiteView should not have the following line:</p>
  
  <pre><code>context = super(SiteView, self).get(*args, **kwargs)
  </code></pre>
  
  <p>This is because the View class does NOT have any get method.</p>