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

Decorate models instead of their __str__ method #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*,
Expand All @@ -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

Expand Down Expand Up @@ -156,6 +156,7 @@ class Attribute(models.Model):
change it's datatype.
'''

@python_2_unicode_compatible

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the class Mate has no mthod str, maybe should add "@python_2_unicode_compatible" at its father class Attribute, this works for me

class Meta(object):
ordering = ['content_type', 'name']
unique_together = ('site', 'content_type', 'slug')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down