Complete the code to import the Django middleware base class.
from django.utils.deprecation import [1]
The MiddlewareMixin is the base class used to create custom middleware in Django.
Complete the method name to process a request in middleware.
def [1](self, request): # Your code here return None
The process_request method is called before the view is executed to process the incoming request.
Fix the error in the middleware class definition by completing the base class.
class AuthMiddleware([1]): def process_request(self, request): if not request.user.is_authenticated: # Redirect or deny access pass
The middleware class must inherit from MiddlewareMixin to work properly in Django.
Fill both blanks to check if the user is authenticated and redirect if not.
def process_request(self, request): if not request.user.[1]: return [2]('/login/')
Use is_authenticated to check user status and HttpResponseRedirect to redirect to login.
Fill all three blanks to import HttpResponseRedirect, define middleware class, and implement process_request.
from django.http import [1] class [2]([3]): def process_request(self, request): if not request.user.is_authenticated: return HttpResponseRedirect('/login/')
Import HttpResponseRedirect, define AuthMiddleware class inheriting from MiddlewareMixin to create authentication middleware.