From 0ec81712bf35b6a339f7d6a7240ea687423b6f84 Mon Sep 17 00:00:00 2001 From: Francesc Lapedriza Date: Tue, 10 Jul 2018 18:32:49 +0200 Subject: [PATCH] Decorate models instead of their __str__ method --- eav/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eav/models.py b/eav/models.py index b5ea562..93a67aa 100644 --- a/eav/models.py +++ b/eav/models.py @@ -51,6 +51,7 @@ from .fields import EavSlugField, EavDatatypeField +@python_2_unicode_compatible class EnumValue(models.Model): ''' *EnumValue* objects are the value 'choices' to multiple choice @@ -83,11 +84,11 @@ class EnumValue(models.Model): value = models.CharField(_(u"value"), db_index=True, unique=True, max_length=50) - @python_2_unicode_compatible def __str__(self): return self.value +@python_2_unicode_compatible class EnumGroup(models.Model): ''' *EnumGroup* objects have two fields- a *name* ``CharField`` and *enums*, @@ -101,7 +102,6 @@ class EnumGroup(models.Model): enums = models.ManyToManyField(EnumValue, verbose_name=_(u"enum group")) - @python_2_unicode_compatible def __str__(self): return self.name @@ -156,6 +156,7 @@ class Attribute(models.Model): change it's datatype. ''' + @python_2_unicode_compatible class Meta(object): ordering = ['content_type', 'name'] unique_together = ('site', 'content_type', 'slug') @@ -322,11 +323,11 @@ def save_value(self, entity, value): value_obj.value = value value_obj.save() - @python_2_unicode_compatible def __str__(self): return u"%s.%s (%s)" % (self.content_type, self.name, self.get_datatype_display()) +@python_2_unicode_compatible class Value(models.Model): ''' Putting the **V** in *EAV*. This model stores the value for one particular @@ -406,7 +407,6 @@ def _set_value(self, new_value): value = property(_get_value, _set_value) - @python_2_unicode_compatible def __str__(self): return u"%s - %s: \"%s\"" % (self.entity, self.attribute.name, self.value)