You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with circular imports. As described in the documentation, I have a ModelIndex defined for a model in app_name/bungiesearch_indices.py. I necessarily import the model in bungiesearch_indices.py.
Also as described in the documentation, I do from "bungiesearch.managers import BungiesearchManager" in app_name/models.py and set objects = BungiesearchManager() on the relevant model.
In my settings.py, I have BUNGIESEARCH setting with an INDICES key that points to 'appname.bungiesearch_indices'.
When my project loads, my model is imported, which tries to import BungiesearchManager, which (by loading Bungiesearch in bungiesearch/init.py) tries to load the indices. Trying to load the indices requires loading my model, which requires BungiesearchManager to be imported, etc.
If I remove the BungiesearchManager import (and the objects = BungiesearchManager()), everything loads fine, but then I can't use BungiesearchManager on the models.
Is there a solution to this? Normal solutions to circular imports (like importing inside a function) don't work in this case.
The text was updated successfully, but these errors were encountered:
I'm having an issue with circular imports. As described in the documentation, I have a ModelIndex defined for a model in app_name/bungiesearch_indices.py. I necessarily import the model in bungiesearch_indices.py.
Also as described in the documentation, I do from "bungiesearch.managers import BungiesearchManager" in app_name/models.py and set objects = BungiesearchManager() on the relevant model.
In my settings.py, I have BUNGIESEARCH setting with an INDICES key that points to 'appname.bungiesearch_indices'.
When my project loads, my model is imported, which tries to import BungiesearchManager, which (by loading Bungiesearch in bungiesearch/init.py) tries to load the indices. Trying to load the indices requires loading my model, which requires BungiesearchManager to be imported, etc.
If I remove the BungiesearchManager import (and the objects = BungiesearchManager()), everything loads fine, but then I can't use BungiesearchManager on the models.
Is there a solution to this? Normal solutions to circular imports (like importing inside a function) don't work in this case.
The text was updated successfully, but these errors were encountered: