code: def anonymous_required(function):
      
  
      def wrapper(*args, **kwargs):
          if args[0].user.is_authenticated():
              url = settings.ANONYMOUS_REQUIRED_REDIRECT_URL
              return HttpResponseRedirect(reverse(url))
          return function(*args, **kwargs)
  
      return wrapper
docs: Redirect to user profile if user is already logged-in