Skip to content

Commit 522ee3f

Browse files
authored
Update models.py for python3
according to https://docs.djangoproject.com/en/1.11/topics/python3/ I added compatibility for python3
1 parent e3ba3ba commit 522ee3f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

eav/models.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
Classes
3333
-------
3434
'''
35+
from __future__ import unicode_literals
3536
from builtins import object
3637

3738

@@ -44,6 +45,7 @@
4445
from django.contrib.sites.models import Site
4546
from django.contrib.sites.managers import CurrentSiteManager
4647
from django.conf import settings
48+
from django.utils.encoding import python_2_unicode_compatible
4749

4850
from .validators import *
4951
from .fields import EavSlugField, EavDatatypeField
@@ -81,9 +83,10 @@ class EnumValue(models.Model):
8183
value = models.CharField(_(u"value"), db_index=True,
8284
unique=True, max_length=50)
8385

84-
def __unicode__(self):
86+
@python_2_unicode_compatible
87+
def __str__(self):
8588
return self.value
86-
89+
8790

8891
class EnumGroup(models.Model):
8992
'''
@@ -98,7 +101,8 @@ class EnumGroup(models.Model):
98101

99102
enums = models.ManyToManyField(EnumValue, verbose_name=_(u"enum group"))
100103

101-
def __unicode__(self):
104+
@python_2_unicode_compatible
105+
def __str__(self):
102106
return self.name
103107

104108

@@ -318,7 +322,8 @@ def save_value(self, entity, value):
318322
value_obj.value = value
319323
value_obj.save()
320324

321-
def __unicode__(self):
325+
@python_2_unicode_compatible
326+
def __str__(self):
322327
return u"%s.%s (%s)" % (self.content_type, self.name, self.get_datatype_display())
323328

324329

@@ -401,7 +406,8 @@ def _set_value(self, new_value):
401406

402407
value = property(_get_value, _set_value)
403408

404-
def __unicode__(self):
409+
@python_2_unicode_compatible
410+
def __str__(self):
405411
return u"%s - %s: \"%s\"" % (self.entity, self.attribute.name,
406412
self.value)
407413

0 commit comments

Comments
 (0)