title: Why do I need to decorate login_required decorator with @method_decorator
body: <p>I am trying to understand the code for the mixins posted at <a href="http://brack3t.com/our-custom-mixins.html" rel="nofollow">this blog post</a>.</p>
  
  <p>These mixins call the <code>login_required</code> decorator from <code>django.contrib.auth.decorators</code> within the mixins , but they do so decorated by the <code>method_decorator</code> from <code>django.utils.decorators</code>.
  In the sample code below I dont understand why I need to decorate the <code>login_required</code> decorator .</p>
  
  <pre><code>from django.utils.decorators import method_decorator
  from django.contrib.auth.decorators import login_required
  class LoginRequiredMixin(object):
      """
      View mixin which verifies that the user has authenticated.
  
      NOTE:
          This should be the left-most mixin of a view.
      """
      # Why do I need to decorate login_required here
      @method_decorator(login_required)
      def dispatch(self, *args, **kwargs):
          return super(LoginRequiredMixin, self).dispatch(*args, **kwargs) 
  </code></pre>
  
  <p>The <code>method_decorator</code> decorator says it is used to "Converts a function decorator into a method decorator" But in test code I can use my decorator even without the method_decorator.</p>
  
  <p>My decorator</p>
  
  <pre><code>def run_eight_times(myfunc):
      def inner_func(*args, **kwargs):
          for i in range(8):
              myfunc(*args, **kwargs)
      return inner_func 
  </code></pre>
  
  <p>My class which calls the above decorator directly produces the same result as if I called the decorator decorated by <code>method_decorator</code></p>
  
  <pre><code>from django.utils.decorators import method_decorator
  class Myclass(object):
  
      def __init__(self,name,favorite_dish):
          self.name = name
          self.favorite_dish = favorite_dish
  
      # This next line is not required
      #@method_decorator(run_eight_times)
      @run_eight_times
      def undecorated_function(self):
          print "%s likes spam in his favorite dish %s" % (self.name,self.favorite_dish) 
  </code></pre>