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. Redirect Multiple Domains to a Single Domain by rpoulton 5 years, 8 months ago
  2. Sophisticated order_by sorting by mawi 6 months, 1 week ago
  3. Limit ForeignKey filter values to those that have a relationship with current model by overclocked 2 years, 7 months ago
  4. IsNullFieldListFilter by ssokolow 12 months ago
  5. Severity codes in user messages by cconnell 4 years, 5 months ago

Comments

(Forgotten your password?)