Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'basestring' is not defined #57

Open
ignacionf opened this issue Aug 24, 2016 · 7 comments
Open

NameError: name 'basestring' is not defined #57

ignacionf opened this issue Aug 24, 2016 · 7 comments

Comments

@ignacionf
Copy link

ignacionf commented Aug 24, 2016

i has this error in a clean code:

14:25 $ git diff
diff --git a/requeriments.txt b/requeriments.txt
index 47d501b..5f36098 100644
--- a/requeriments.txt
+++ b/requeriments.txt
@@ -29,3 +29,5 @@ django-ajax-selects==1.4.1
 Babel==2.3.4
 django-compressor==2.1
 django-libsass==0.7
+elasticsearch==2.3.0
+git+https://github.com/liberation/django_elasticsearch.git
diff --git a/uniresto/products/models.py b/uniresto/products/models.py
index c78781d..4928754 100644
--- a/uniresto/products/models.py
+++ b/uniresto/products/models.py
@@ -9,6 +9,8 @@ from imagekit.processors import ResizeToFill
 from image_cropping import ImageRatioField
 from enum import Enum
 from django.utils.text import slugify
+from django_elasticsearch.models import EsIndexable
+


 COMBO_PRODUCT_TYPES = (
@@ -166,7 +168,7 @@ class Category(models.Model):
         verbose_name_plural = 'Categorias de productos (Pasta, carnes, etc).'


-class ProductTemplates(models.Model):
+class ProductTemplates(EsIndexable, models.Model):
     """
     Almacena plantillas de productos por categorias. Se utiliza para agilizar el registro de todos los productos
     de marca comercial o no ya definidos.
14:36 $ 

in settings:

ELASTICSEARCH_URL='http://localhost:9200'
ELASTICSEARCH_AUTO_INDEX=True
ELASTICSEARCH_DEFAULT_INDEX='uniresto'

Tracktrace:

NameError                                 Traceback (most recent call last)
<ipython-input-3-be67e0bf0776> in <module>()
----> 1 ProductTemplates(name="caca", category=o, celiac=False, delivery=True, consumed_in_store=True, max_choices=1).save()

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/models.py in save(self, *args, **kwargs)
     52     def save(self, *args, **kwargs):
     53         self._raise_no_db_operation()
---> 54         super(EsIndexable, self).save(*args, **kwargs)
     55 
     56     def delete(self, *args, **kwargs):

/home/ignacio/uniresto/lib/python3.5/site-packages/django/db/models/base.py in save(self, force_insert, force_update, using, update_fields)
    708 
    709         self.save_base(using=using, force_insert=force_insert,
--> 710                        force_update=force_update, update_fields=update_fields)
    711     save.alters_data = True
    712 

/home/ignacio/uniresto/lib/python3.5/site-packages/django/db/models/base.py in save_base(self, raw, force_insert, force_update, using, update_fields)
    745         if not meta.auto_created:
    746             signals.post_save.send(sender=origin, instance=self, created=(not updated),
--> 747                                    update_fields=update_fields, raw=raw, using=using)
    748 
    749     save_base.alters_data = True

/home/ignacio/uniresto/lib/python3.5/site-packages/django/dispatch/dispatcher.py in send(self, sender, **named)
    199 
    200         for receiver in self._live_receivers(sender):
--> 201             response = receiver(signal=self, sender=sender, **named)
    202             responses.append((receiver, response))
    203         return responses

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/models.py in es_save_callback(sender, instance, **kwargs)
     70     if not issubclass(sender, EsIndexable):
     71         return
---> 72     instance.es.do_index()
     73 
     74 

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/managers.py in wrapper(*args, **kwargs)
     44         if args[0].instance is None:
     45             raise AttributeError("This method requires an instance of the model.")
---> 46         return f(*args, **kwargs)
     47     return wrapper
     48 

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/managers.py in do_index(self)
    122     @needs_instance
    123     def do_index(self):
--> 124         body = self.serialize()
    125         es_client.index(index=self.index,
    126                         doc_type=self.doc_type,

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/managers.py in wrapper(*args, **kwargs)
     44         if args[0].instance is None:
     45             raise AttributeError("This method requires an instance of the model.")
---> 46         return f(*args, **kwargs)
     47     return wrapper
     48 

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/managers.py in serialize(self)
    101         Note: by default, will use all the model's fields.
    102         """
--> 103         serializer = self.get_serializer()
    104         return serializer.serialize(self.instance)
    105 

/home/ignacio/uniresto/lib/python3.5/site-packages/django_elasticsearch/managers.py in get_serializer(self, **kwargs)
     88     def get_serializer(self, **kwargs):
     89         serializer = self.model.Elasticsearch.serializer_class
---> 90         if isinstance(serializer, basestring):
     91             module, kls = self.model.Elasticsearch.serializer_class.rsplit(".", 1)
     92             mod = importlib.import_module(module)

NameError: name 'basestring' is not defined
@lauxley
Copy link
Contributor

lauxley commented Aug 25, 2016

Yep the code is still not python3 ready :(

@ignacionf
Copy link
Author

ouch....

ok, i can help with this, but i need time.

@ignacionf
Copy link
Author

ignacionf added a commit to ignacionf/django-elasticsearch that referenced this issue Aug 25, 2016
@ahopkins
Copy link

Is anyone working on upgrading this to work with Python3?

@ignacionf
Copy link
Author

My fork is for py3. Can you test?

El 23 sept. 2016 2:37 a. m., "Adam Hopkins" [email protected]
escribió:

Is anyone working on upgrading this to work with Python3?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#57 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGLRAl4G0jAf0LRTSDMvQfwlqmuvplwks5qs3OxgaJpZM4JsQ4g
.

@ahopkins
Copy link

Awesome. Yeah, I'll take a look next week and see if I can help out.

On Fri, Sep 23, 2016, 15:31 Ignacio Feijoo [email protected] wrote:

My fork is for py3. Can you test?

El 23 sept. 2016 2:37 a. m., "Adam Hopkins" [email protected]
escribió:

Is anyone working on upgrading this to work with Python3?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<
#57 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AAGLRAl4G0jAf0LRTSDMvQfwlqmuvplwks5qs3OxgaJpZM4JsQ4g

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#57 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKJfXvDTXXM3TwJnazgtck9XKN7ADfgks5qs8awgaJpZM4JsQ4g
.

MightySCollins added a commit to MightySCollins/django-elasticsearch that referenced this issue Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants