From b94ed429b5ef19823f2672a7df889035ed2510e4 Mon Sep 17 00:00:00 2001 From: Loris Cro Date: Tue, 28 Jun 2016 12:52:50 +0200 Subject: [PATCH] py3 compatibility of basestring checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aliased ‘basestring’ with ‘str’ for py3 compatibility --- django_elasticsearch/managers.py | 6 ++++++ django_elasticsearch/tests/test_serializer.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/django_elasticsearch/managers.py b/django_elasticsearch/managers.py index c62a7e7..c5d7f2a 100644 --- a/django_elasticsearch/managers.py +++ b/django_elasticsearch/managers.py @@ -11,6 +11,12 @@ from django_elasticsearch.query import EsQueryset from django_elasticsearch.client import es_client + +try: + basestring #py2 +except NameError: + basestring = str #py3 + # Note: we use long/double because different db backends # could store different sizes of numerics ? # Note: everything else is mapped to a string diff --git a/django_elasticsearch/tests/test_serializer.py b/django_elasticsearch/tests/test_serializer.py index 5dd1def..93436a8 100644 --- a/django_elasticsearch/tests/test_serializer.py +++ b/django_elasticsearch/tests/test_serializer.py @@ -10,6 +10,11 @@ from test_app.models import Test2Model +try: + basestring #py2 +except NameError: + basestring = str #py3 + class CustomSerializer(EsJsonSerializer): def serialize_char(self, instance, field_name): return u'FOO'