Fixing AppNotReady errors in register()

This commit is contained in:
Dave Hall 2016-03-01 09:48:50 +00:00
parent 5ed08d55cc
commit 97a7ef066b

View file

@ -11,7 +11,6 @@ from weakref import WeakValueDictionary
from django.conf import settings
from django.core.signals import request_finished
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Q
from django.db.models.query import QuerySet
@ -424,6 +423,7 @@ class SearchEngine(object):
def _get_entries_for_obj(self, obj):
"""Returns a queryset of entries associate with the given obj."""
from django.contrib.contenttypes.models import ContentType
from watson.models import SearchEntry, has_int_pk
model = obj.__class__
content_type = ContentType.objects.get_for_model(model)
@ -449,6 +449,7 @@ class SearchEngine(object):
def _update_obj_index_iter(self, obj):
"""Either updates the given object index, or yields an unsaved search entry."""
from django.contrib.contenttypes.models import ContentType
from watson.models import SearchEntry
model = obj.__class__
adapter = self.get_adapter(model)
@ -501,6 +502,7 @@ class SearchEngine(object):
def _create_model_filter(self, models):
"""Creates a filter for the given model/queryset list."""
from django.contrib.contenttypes.models import ContentType
from watson.models import has_int_pk
filters = Q()
for model in models: