How to fix RuntimeError: Working outside of request context in Python | DevErrors