0

I want to include a custom field in the watson model SearchEntry as almost all my searches will include it.

I've created a custom engine that creates a new field and index on install and linked to in settings:

   WATSON_BACKEND = "tools.custombackend.SearchBackend"

I can see how I am going to include it in the search by creating a custom SearchAdapter that is setup with I register the models.

However, I can't work out how to get my value into the model. I thought I could use signals, but it's never getting triggered.

This is signals.py

from django.db.models.signals import pre_save, pre_delete, post_save, post_delete
from django.dispatch import receiver
from django.conf import settings
from watson.models import SearchEntry

@receiver(post_save, sender=SearchEntry)
def model_post_save(sender, **kwargs):
    never gets here....

and I'm calling it from one of the apps.py that I know is getting triggered.

class ToolsAppConfig(AppConfig):
    name = "tools"
    def ready(self):
        print 'loading signals'
        import tools.signals

Have I setup the signal receiver incorrectly? Maybe there is a better way? The value I want to save in searchentry is in the object being indexed.

PhoebeB
  • 8,434
  • 8
  • 57
  • 76
  • Are you sure SearchEntry.post_save is being sent? – Ben Hare Oct 26 '15 at 15:52
  • I thought post_save was automatically sent by django? Do you know how I would check that the signal is being sent? – PhoebeB Oct 27 '15 at 16:17
  • They can not be. If save is overwritten, for instance, and doesn't call the parent classes 'save' then it won't send a signal. Could you expand on where you're saving a SearchEntry? – Ben Hare Oct 27 '15 at 17:53

0 Answers0