Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

All backends: fixed more_like_this & deferreds

Django removed the get_proxied_model helper function in the 1.3 dev
cycle:

https://code.djangoproject.com/ticket/17678

This change adds support for the simple new property access used by 1.3+

BACKWARD INCOMPATIBLE: Django 1.2 is no longer supported
  • Loading branch information...
commit c8b601be0b1fd814663ecc4fc30545573c74b7d9 1 parent 13e5a49
@acdha acdha authored
View
2  README.rst
@@ -43,7 +43,7 @@ Requirements
Haystack has a relatively easily-met set of requirements.
* Python 2.5+
-* Django 1.2+
+* Django 1.3+
Additionally, each backend has its own requirements. You should refer to
http://docs.haystacksearch.org/dev/installing_search_engines.html for more
View
2  docs/index.rst
@@ -109,7 +109,7 @@ Requirements
Haystack has a relatively easily-met set of requirements.
* Python 2.5+
-* Django 1.2+ (may work on 1.1.2+)
+* Django 1.3+
Additionally, each backend has its own requirements. You should refer to
:doc:`installing_search_engines` for more details.
View
14 haystack/backends/elasticsearch_backend.py
@@ -11,11 +11,7 @@
from haystack.models import SearchResult
from haystack.utils import get_identifier
from haystack.utils import log as logging
-try:
- from django.db.models.sql.query import get_proxied_model
-except ImportError:
- # Likely on Django 1.0
- get_proxied_model = None
+
try:
import requests
except ImportError:
@@ -504,11 +500,9 @@ def more_like_this(self, model_instance, additional_query_string=None,
if not self.setup_complete:
self.setup()
- # Handle deferred models.
- if get_proxied_model and hasattr(model_instance, '_deferred') and model_instance._deferred:
- model_klass = get_proxied_model(model_instance._meta)
- else:
- model_klass = type(model_instance)
+ # Deferred models will have a different class ("RealClass_Deferred_fieldname")
+ # which won't be in our registry:
+ model_klass = model_instance._meta.concrete_model
index = connections[self.connection_alias].get_unified_index().get_index(model_klass)
field_name = index.get_content_field()
View
14 haystack/backends/solr_backend.py
@@ -9,11 +9,7 @@
from haystack.models import SearchResult
from haystack.utils import get_identifier
from haystack.utils import log as logging
-try:
- from django.db.models.sql.query import get_proxied_model
-except ImportError:
- # Likely on Django 1.0
- get_proxied_model = None
+
try:
from pysolr import Solr, SolrError
except ImportError:
@@ -264,11 +260,9 @@ def more_like_this(self, model_instance, additional_query_string=None,
limit_to_registered_models=None, result_class=None, **kwargs):
from haystack import connections
- # Handle deferred models.
- if get_proxied_model and hasattr(model_instance, '_deferred') and model_instance._deferred:
- model_klass = get_proxied_model(model_instance._meta)
- else:
- model_klass = type(model_instance)
+ # Deferred models will have a different class ("RealClass_Deferred_fieldname")
+ # which won't be in our registry:
+ model_klass = model_instance._meta.concrete_model
index = connections[self.connection_alias].get_unified_index().get_index(model_klass)
field_name = index.get_content_field()
View
14 haystack/backends/whoosh_backend.py
@@ -15,6 +15,7 @@
from haystack.models import SearchResult
from haystack.utils import get_identifier
from haystack.utils import log as logging
+
try:
import json
except ImportError:
@@ -22,11 +23,6 @@
import simplejson as json
except ImportError:
from django.utils import simplejson as json
-try:
- from django.db.models.sql.query import get_proxied_model
-except ImportError:
- # Likely on Django 1.0
- get_proxied_model = None
try:
import whoosh
@@ -448,11 +444,9 @@ def more_like_this(self, model_instance, additional_query_string=None,
if not self.setup_complete:
self.setup()
- # Handle deferred models.
- if get_proxied_model and hasattr(model_instance, '_deferred') and model_instance._deferred:
- model_klass = get_proxied_model(model_instance._meta)
- else:
- model_klass = type(model_instance)
+ # Deferred models will have a different class ("RealClass_Deferred_fieldname")
+ # which won't be in our registry:
+ model_klass = model_instance._meta.concrete_model
field_name = self.content_field_name
narrow_queries = set()
Please sign in to comment.
Something went wrong with that request. Please try again.