haystack_signal_processor let you use custom signal processor to initiate index for certain models.
I have in my settings.py
HAYSTACK_SIGNAL_PROCESSOR='my_app.signals.MySignalProcessor'
(this imports signals.py
so. this is settings -> signals)
then inside my signals.py
I havefrom my_app.models import my_model
# to connect my_model
And my_app.models.py has from django.conf import settings
(signals -> models -> settings)
How do I resolve this circular import?
taken from https://github.com/PitonFoundation/atlas/commit/cc0abcb
Instead of importing the model on top of your signals.py file, import the models in the methods of your custom SignalProcessor using get_model:
from django.db.models.loading import get_model
class MySignalProcessor(signals.BaseSignalProcessor):
def setup(self):
MyModel = get_model('myApp', 'MyModel')
models.signals.post_save.connect(self.handle_save, sender=MyModel)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With