title: Customize Django class base view at global (project wide)
body: <p>I am developer a Django website which will do SSO for most of the web pages, and I was using Class based views extensively, the <a href="https://docs.djangoproject.com/en/dev/topics/class-based-views/intro/#decorating-the-class" rel="nofollow">official documentation</a> said that we can decorate class based view in this way:</p>
  
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.utils.decorators import method_decorator
  from django.views.generic import TemplateView
  
  class ProtectedView(TemplateView):
      template_name = 'secret.html'
  
      @method_decorator(login_required)
      def dispatch(self, *args, **kwargs):
          return super(ProtectedView, self).dispatch(*args, **kwargs)
  </code></pre>
  
  <p>I've implemented a customized <code>sso_login_required</code> decorator, but since most of my pages will do SSO,  I believe doing above for most of my views is <strong>absolutely not the right way</strong>, I was thinking doing that at a global level, I guess I have two options to implement/override the dispatch method above:</p>
  
  <ol>
  <li>Create my <code>BaseView</code> class which inherits from <code>django.views.generic.base.View</code>, and let all my views inherits from this customized BaseView.</li>
  <li>Override <code>dispatch</code> method of <code>django.views.generic.base.View</code> at my project level</li>
  </ol>
  
  <p>What is the best practice here according to my requirement (SSO for most pages)? Any recommendation or suggestions are highly appreciated!</p>