How do I stop circular importing in python for Flask?
Asked a year ago
I'm building a web-application with Flask (I'm a bit new to it, although I have experience with Python), and I keep getting the message: AttributeError: partially initialized module 'a' has no attribute 'A'. Is it a circular import error? Thanks.
Edmund Lynn
Saturday, October 08, 2022
If you're working on a slightly bigger app, the easiest way to handle circular imports is by changing Flask's configuarion dictioary. You can do this with the command "app.config["KEY"] = "key1"" in app1.py, and "app.config["KEY"]="key2" in app2.py. If the app is smaller, then a better solution would be putting your apps in seperate modules so that there are no circular imports.
Please follow our Community Guidelines