Skip to content

Commit

Permalink
Merge pull request #52 from jiargei/patch-1
Browse files Browse the repository at this point in the history
Update models.py for python3
  • Loading branch information
Hamdi Sahloul committed Apr 3, 2018
2 parents e3ba3ba + 522ee3f commit 41e99fa
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions eav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Classes
-------
'''
from __future__ import unicode_literals
from builtins import object


Expand All @@ -44,6 +45,7 @@
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
from django.conf import settings
from django.utils.encoding import python_2_unicode_compatible

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

def __unicode__(self):
@python_2_unicode_compatible
def __str__(self):
return self.value


class EnumGroup(models.Model):
'''
Expand All @@ -98,7 +101,8 @@ class EnumGroup(models.Model):

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

def __unicode__(self):
@python_2_unicode_compatible
def __str__(self):
return self.name


Expand Down Expand Up @@ -318,7 +322,8 @@ def save_value(self, entity, value):
value_obj.value = value
value_obj.save()

def __unicode__(self):
@python_2_unicode_compatible
def __str__(self):
return u"%s.%s (%s)" % (self.content_type, self.name, self.get_datatype_display())


Expand Down Expand Up @@ -401,7 +406,8 @@ def _set_value(self, new_value):

value = property(_get_value, _set_value)

def __unicode__(self):
@python_2_unicode_compatible
def __str__(self):
return u"%s - %s: \"%s\"" % (self.entity, self.attribute.name,
self.value)

Expand Down

0 comments on commit 41e99fa

Please sign in to comment.