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.
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.