I am trying to make SignalProcessor as per haystack documentation, here is my code:
from haystack.signals import RealtimeSignalProcessor
from products.models import ProductCreateModel
from django.db import models
from star_ratings.models import Rating
class BatchingSignalProcessor(RealtimeSignalProcessor):
def handle_save(self):
using_backends = self.connection_router.for_write(instance=instance)
for using in using_backends:
try:
index = self.connections[using].get_unified_index().get_index(instance.__class__)
index.update_object(instance, using=using)
except NotHandled:
# TODO: Maybe log it or let the exception bubble?
pass
def setup(self):
models.signals.post_save.connect(self.handle_save, sender=Rating)
Full error:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000240811ED400>
Traceback (most recent call last):
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\core\management\commands\runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\core\management\__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\apps\registry.py", line 120, in populate
app_config.ready()
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\haystack\apps.py", line 28, in ready
self.signal_processor = signal_processor_class(connections, connection_router)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\haystack\signals.py", line 20, in __init__
self.setup()
File "c:\Users\lenovo\Desktop\My_Django_Stuff\bekaim\search\signals.py", line 21, in setup
models.signals.post_save.connect(self.handle_save, sender=Rating)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\db\models\signals.py", line 28, in connect
weak=weak, dispatch_uid=dispatch_uid,
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\db\models\signals.py", line 23, in _lazy_method
return partial_method(sender)
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\dispatch\dispatcher.py", line 90, in connect
raise ValueError("Signal receivers must accept keyword arguments (**kwargs).")
ValueError: Signal receivers must accept keyword arguments (**kwargs)
Here you can see documentation - https://django-haystack.readthedocs.io/en/v2.2.0/signal_processors.html#custom-signalprocessors
Here is what I find in django documentation but unable to figure out solution - https://docs.djangoproject.com/en/2.0/_modules/django/dispatch/dispatcher/
How to resolve this error ?
def handle_save(self, **kwargs)
? – Endearment