code: def login_required(func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):
      
      def decorator(view_func):
          @functools.wraps(view_func, assigned=available_attrs(view_func))
          def _wrapped_view(request, *args, **kwargs):
              if is_authenticated(request.user):
                  return view_func(request, *args, **kwargs)
              return handle_redirect_to_login(
                  request,
                  redirect_field_name=redirect_field_name,
                  login_url=login_url
              )
          return _wrapped_view
      if func:
          return decorator(func)
      return decorator
docs: Decorator for views that checks that the user is logged in, redirecting
      to the log in page if necessary.