-
-
Save jezdez/2000f763e15c260c0666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ungettext_lazy | |
class Fruit(models.Model): | |
name = models.CharField(max_length=100) | |
def __unicode__(self): | |
return self.name | |
class Meta: | |
verbose_name = _("fruit") | |
verbose_name_plural = lambda count: ungettext_lazy('fruit', 'fruits', count) | |
# backward compaat implementations for main model class | |
class Model(models.Model): | |
def get_verbose_name(self): | |
return self._meta.verbose_name | |
def get_verbose_name_plural(self, count=None): | |
return self._meta.verbose_name_plural | |
class Vegetable(models.Model): | |
name = models.CharField(max_length=100) | |
def __unicode__(self): | |
return self.name | |
def get_verbose_name(self): | |
return _("fruit") | |
def get_verbose_name_plural(self, count): | |
return ungettext_lazy('vegetable', 'vegetables', count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment