Possessive-aware unicode for models

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class List(models.Model):
    profile = models.ForeignKey(Profile)

    def __unicode__(self):
        
        # Represent instance with 's on end unless person's name ends with s
        if unicode(self.profile)[-1] == 's':
            return "%s' bucketlist" % self.profile
        else:
            return "%s's bucketlist" % self.profile

More like this

  1. gettext parachut for python 2.3 with unicode and utf-8 by angerman 4 years, 11 months ago
  2. Validation for full e-mails (e.g. "Joe Hacker <joe@hacker.com>") by akaihola 1 month, 2 weeks ago
  3. Convert Unicode to ASCII by coordt 4 years ago
  4. UnicodeReprMixIn by ashcrow 3 years, 1 month ago
  5. The model field subclass returns string generated from the list of choices. by I159 2 months, 3 weeks ago

Comments

(Forgotten your password?)