1. offline
  2. django-tsearch2

Source

django-tsearch2 / tsearch2 / signals.py


def handler(sender,  instance, **kwargs):
    """
    A convience signal that provides an update_index method for object instances,
    as well as automatic index updating. The index is stored as a tsvector column on the
    model's table. At model registry you can provide 'auto_reindex' boolean parameter to 
    control whether the index is automatically updated when save is called.
    """
    manager = getattr(sender, sender._meta.search_manager_attr)
    if sender.auto_reindex:
        manager.update_index()
    else:
        manager.update_index(pk=instance.pk)