79421777

Date: 2025-02-07 18:09:22
Score: 1
Natty:
Report link

I am trying to do something similar. I avoided your error by checking if there is a request context:

if has_request_context():
        return current_user.get_id() if current_user.is_authenticated else "Anonymous"
    return "System"

My implementation is with flask-login but the point is to use has_request_context():

from flask import has_request_context
Reasons:
  • Blacklisted phrase (1): I am trying to
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: León