4. Real-time update of search index on Django admin actions
from haystack.management.commands.update_index import Command as UpdateIndexCommanddefon_superuser_action(sender,**kwargs): action = kwargs['action']if action in('delete','delete_selected'): models = kwargs['models']for model in models:UpdateIndexCommand().update_model(model)
5. Real-time update of search index on Django signals
6. Real-time update of search index based on user permissions
7. Real-time update of search index based on custom conditions
8. Real-time update of search index with custom parameters
9. Real-time update of search index with custom priority
10. Real-time update of search index with custom backend
11. Real-time update of search index with custom callbacks
12. Real-time update of search index with multiple updates
13. Real-time update of search index with custom transformers
14. Real-time update of search index with custom context
15. Real-time update of search index with custom signal processors
16. Real-time update of search index with custom routers
17. Real-time update of search index with custom indexes
18. Real-time update of search index with multiple search engines
19. Real-time update of search index with multiple backends
20. Real-time update of search index with multiple indexes
21. Real-time update of search index with multiple backends and indexes
22. Real-time update of search index with custom result handlers
23. Real-time update of search index with custom result managers
24. Real-time update of search index with custom search models
25. Real-time update of search index with custom batch processors
26. Real-time update of search index with custom commit processors
27. Real-time update of search index with custom per-model settings
28. Real-time update of search index with custom per-app settings
29. Real-time update of search index with custom per-site settings
30. Real-time update of search index with custom per-request settings
31. Real-time update of search index with custom per-app settings and Middleware
32. Real-time update of search index with custom per-app settings and Signal Processor
33. Real-time update of search index with custom per-request settings and Signal Processor
34. Real-time update of search index with custom per-model settings, Middleware, and Signal Processor
35. Real-time update of search index with custom per-app settings, Middleware, and Signal Processor
36. Real-time update of search index with custom per-site settings, Middleware, and Signal Processor
from haystack import signals
def on_model_saved(sender, **kwargs):
obj = kwargs['instance']
if isinstance(obj, MyModel):
index.update_object(obj, using='my_custom_index')
signals.post_save.connect(on_model_saved, dispatch_uid='myproject.mymodule.on_mymodel_saved')
from haystack import signals
def on_model_saved(sender, **kwargs):
obj = kwargs['instance']
if obj._meta.app_label == 'myproject.myapp':
index.update_object(obj, using='my_custom_index')
signals.post_save.connect(on_model_saved, dispatch_uid='myproject.mymodule.on_myapp_saved')
from haystack import signals
def on_model_saved(sender, **kwargs):
obj = kwargs['instance']
if obj._meta.site.name == 'mysite':
index.update_object(obj, using='my_custom_index')
signals.post_save.connect(on_model_saved, dispatch_uid='myproject.mymodule.on_mysite_saved')
from django import middleware
from haystack import signals
class MyMiddleware(middleware.MiddlewareMixin):
def process_request(self, request):
if request.user.is_authenticated:
signals.REALTIME_SIGNAL_PROCESSOR.update_settings(using='my_custom_index')
signals.post_save.connect(on_model_saved, dispatch_uid='myproject.mymodule.on_authenticated_user_saved')
from haystack import signals
def on_model_saved(sender, **kwargs):
obj = kwargs['instance']
if obj._meta.app_label == 'myproject.myapp' and user.is_authenticated:
index.update_object(obj, using='my_custom_index')
signals.post_save.connect(on_model_saved, dispatch_uid='myproject.mymodule.on_myapp_saved_for_authenticated_user')
from haystack import signals
class MySignalProcessor(BaseSignalProcessor):
def update(self, sender, **kwargs):
obj = kwargs['instance']
if isinstance(obj, MyModel) and user.is_authenticated:
index.update_object(obj, using='my_custom_index')
# settings.py
HAYSTACK_SIGNAL_PROCESSOR = 'myproject.mymodule.MySignalProcessor'
from haystack import signals
class MySignalProcessor(BaseSignalProcessor):
def update(self, sender, **kwargs):
obj = kwargs['instance']
request = kwargs['request']
if isinstance(obj, MyModel) and request.user.is_authenticated:
index.update_object(obj, using='my_custom_index')
# settings.py
HAYSTACK_SIGNAL_PROCESSOR = 'myproject.mymodule.MySignalProcessor'
from haystack import signals
def on_model_saved(sender, **kwargs):
obj = kwargs['instance']
request = kwargs['request']
if isinstance(obj, MyModel) and request.user.is_authenticated:
index.update_object(obj, using='my_custom_index')
class MySignalProcessor(BaseSignalProcessor):
def update(self, sender, **kwargs):
obj = kwargs['instance']
request = kwargs['request']
if isinstance(obj, MyModel) and request.user.is_authenticated:
index.update_object(obj, using='my_custom_index')
# settings.py
HAYSTACK_SIGNAL_PROCESSOR = 'myproject.mymodule.MySignalProcessor'
from haystack import signals
class MySignalProcessor(BaseSignalProcessor):
def update(self, sender, **kwargs):
obj = kwargs['instance']
request = kwargs['request']
if obj._meta.app_label == 'myproject.myapp' and request.user.is_authenticated:
index.update_object(obj, using='my_custom_index')
# settings.py
HAYSTACK_SIGNAL_PROCESSOR = 'myproject.mymodule.MySignalProcessor'
from haystack import signals
class MySignalProcessor(BaseSignalProcessor):
def update(self, sender, **kwargs):
obj = kwargs['instance']
request = kwargs['request']
if obj._meta.site.name == 'mysite' and request.user.is_authenticated:
index.update_object(obj, using='my_custom_index')
# settings.py
HAYSTACK_SIGNAL_PROCESSOR = 'myproject.mymodule.MySignalProcessor'