Skip to content
This repository was archived by the owner on Dec 4, 2019. It is now read-only.

replacing deprecated approach of get_index() #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions celery_haystack_index/queued_indexer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.db.models import signals
from django.db.models.loading import get_model

from haystack import connections
from haystack import indexes
from haystack import site

from tasks import SearchIndexUpdateTask

def remove_instance_from_index(instance):
model_class = get_model(instance._meta.app_label, instance._meta.module_name)
search_index = site.get_index(model_class)
search_index = connections['default'].get_unified_index.get_index(model_class)
search_index.remove_object(instance)

class QueuedSearchIndex(indexes.SearchIndex):
Expand Down
4 changes: 2 additions & 2 deletions celery_haystack_index/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db.models.loading import get_model

from haystack import site
from haystack import connections
from haystack.management.commands import update_index

from celery.task import Task, PeriodicTask
Expand All @@ -17,7 +17,7 @@ def run(self, app_name, model_name, pk, **kwargs):
try:
model_class = get_model(app_name, model_name)
instance = model_class.objects.get(pk=pk)
search_index = site.get_index(model_class)
search_index = connections['default'].get_unified_index.get_index(model_class)
search_index.update_object(instance)
except Exception, exc:
logger.error(exc)
Expand Down