Permalink
Browse files

better unicode methods

  • Loading branch information...
1 parent d8f7e23 commit fe79a8cf53a7dde5f0810643cc2d7ca702d4819b @beniwohli beniwohli committed Mar 20, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 cmsplugin_text_ng/models.py
@@ -47,6 +47,9 @@ class TextNGVariableBase(models.Model):
text_ng = models.ForeignKey(TextNG, related_name='+')
label = models.CharField(_('label'), max_length=20, validators=[RegexValidator(regex='[_a-z]+', message=_('Only lower case characters.'))])
+ def __unicode__(self):
+ return self.label
+
class Meta:
abstract = True
unique_together = ('text_ng', 'label')
@@ -55,6 +58,9 @@ class Meta:
class TextNGVariableText(TextNGVariableBase):
value = models.TextField(_('value'), null=True, blank=True)
+ def __unicode__(self):
+ return self.label + (' (%s)' % self.value if self.value else '')
+
class Meta:
verbose_name = _('text')
verbose_name_plural = _('texts')

0 comments on commit fe79a8c

Please sign in to comment.