title: Can't import custom Middleware whilst using @decorator_from_middleware. (Non Global Middleware)
body: <p>I was using some custom middleware to check auth of users. This was working great but I don't want to run this middleware on every url. </p>
  
  <p><a href="https://stackoverflow.com/a/2917155/6163866">Suggestions</a> point towards using <code>@decorator_from_middleware</code>
  before each view that you want middleware to run, this would be ideal. Some of my view should be global, others behind auth.</p>
  
  <p>I cant seem to import the middleware to call it in the views file.</p>
  
  <p>My views.py:</p>
  
  <pre><code>from myapp.middleware import *
  
  @decorator_from_middleware(AuthCheckMiddleware)
  def index(request):
      return render(request, "index.html")
  </code></pre>
  
  <p>My myapp.middleware.authCheck.py:</p>
  
  <pre><code>class AuthCheckMiddleware(object):
  def __init__(self, get_response):
      self.get_response = get_response
  
  def __call__(self, request):
      #CHECK AUTH HERE
      response = self.get_response(request)
      return response
  
  def process_exception(self, request, exception): 
      return None
  </code></pre>
  
  <p>The error I get:</p>
  
  <pre><code>  File "/vagrant/myapp/django-project/isadmin/web/views.py", line 93, in &lt;module&gt;
  @decorator_from_middleware(AuthCheckMiddleware)
  NameError: name 'AuthCheckMiddleware' is not defined
  </code></pre>