Loading docs/db-api.txt +1 −1 Original line number Diff line number Diff line Loading @@ -559,7 +559,7 @@ following models:: # ... hometown = models.ForeignKey(City) class Book(meta.Model): class Book(models.Model): # ... author = models.ForeignKey(Person) Loading docs/forms.txt +9 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ We'll take a top-down approach to examining Django's form validation framework, because much of the time you won't need to use the lower-level APIs. Throughout this document, we'll be working with the following model, a "place" object:: from django.db import models PLACE_TYPES = ( (1, 'Bar'), (2, 'Restaurant'), Loading @@ -22,13 +24,13 @@ this document, we'll be working with the following model, a "place" object:: (4, 'Secret Hideout'), ) class Place(meta.Model): name = meta.CharField(maxlength=100) address = meta.CharField(maxlength=100, blank=True) city = meta.CharField(maxlength=50, blank=True) state = meta.USStateField() zip_code = meta.CharField(maxlength=5, blank=True) place_type = meta.IntegerField(choices=PLACE_TYPES) class Place(models.Model): name = models.CharField(maxlength=100) address = models.CharField(maxlength=100, blank=True) city = models.CharField(maxlength=50, blank=True) state = models.USStateField() zip_code = models.CharField(maxlength=5, blank=True) place_type = models.IntegerField(choices=PLACE_TYPES) class Admin: pass Loading docs/i18n.txt +6 −6 Original line number Diff line number Diff line Loading @@ -133,8 +133,8 @@ For example, to translate a model's ``help_text``, do the following:: from django.utils.translation import gettext_lazy class MyThing(meta.Model): name = meta.CharField(help_text=gettext_lazy('This is the help text')) class MyThing(models.Model): name = models.CharField(help_text=gettext_lazy('This is the help text')) In this example, ``gettext_lazy()`` stores a lazy reference to the string -- not the actual translation. The translation itself will be done when the string Loading @@ -145,8 +145,8 @@ If you don't like the verbose name ``gettext_lazy``, you can just alias it as from django.utils.translation import gettext_lazy as _ class MyThing(meta.Model): name = meta.CharField(help_text=_('This is the help text')) class MyThing(models.Model): name = models.CharField(help_text=_('This is the help text')) Always use lazy translations in `Django models`_. And it's a good idea to add translations for the field names and table names, too. This means writing Loading @@ -155,8 +155,8 @@ class, though:: from django.utils.translation import gettext_lazy as _ class MyThing(meta.Model): name = meta.CharField(_('name'), help_text=_('This is the help text')) class MyThing(models.Model): name = models.CharField(_('name'), help_text=_('This is the help text')) class Meta: verbose_name = _('my thing') verbose_name_plural = _('mythings') Loading Loading
docs/db-api.txt +1 −1 Original line number Diff line number Diff line Loading @@ -559,7 +559,7 @@ following models:: # ... hometown = models.ForeignKey(City) class Book(meta.Model): class Book(models.Model): # ... author = models.ForeignKey(Person) Loading
docs/forms.txt +9 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ We'll take a top-down approach to examining Django's form validation framework, because much of the time you won't need to use the lower-level APIs. Throughout this document, we'll be working with the following model, a "place" object:: from django.db import models PLACE_TYPES = ( (1, 'Bar'), (2, 'Restaurant'), Loading @@ -22,13 +24,13 @@ this document, we'll be working with the following model, a "place" object:: (4, 'Secret Hideout'), ) class Place(meta.Model): name = meta.CharField(maxlength=100) address = meta.CharField(maxlength=100, blank=True) city = meta.CharField(maxlength=50, blank=True) state = meta.USStateField() zip_code = meta.CharField(maxlength=5, blank=True) place_type = meta.IntegerField(choices=PLACE_TYPES) class Place(models.Model): name = models.CharField(maxlength=100) address = models.CharField(maxlength=100, blank=True) city = models.CharField(maxlength=50, blank=True) state = models.USStateField() zip_code = models.CharField(maxlength=5, blank=True) place_type = models.IntegerField(choices=PLACE_TYPES) class Admin: pass Loading
docs/i18n.txt +6 −6 Original line number Diff line number Diff line Loading @@ -133,8 +133,8 @@ For example, to translate a model's ``help_text``, do the following:: from django.utils.translation import gettext_lazy class MyThing(meta.Model): name = meta.CharField(help_text=gettext_lazy('This is the help text')) class MyThing(models.Model): name = models.CharField(help_text=gettext_lazy('This is the help text')) In this example, ``gettext_lazy()`` stores a lazy reference to the string -- not the actual translation. The translation itself will be done when the string Loading @@ -145,8 +145,8 @@ If you don't like the verbose name ``gettext_lazy``, you can just alias it as from django.utils.translation import gettext_lazy as _ class MyThing(meta.Model): name = meta.CharField(help_text=_('This is the help text')) class MyThing(models.Model): name = models.CharField(help_text=_('This is the help text')) Always use lazy translations in `Django models`_. And it's a good idea to add translations for the field names and table names, too. This means writing Loading @@ -155,8 +155,8 @@ class, though:: from django.utils.translation import gettext_lazy as _ class MyThing(meta.Model): name = meta.CharField(_('name'), help_text=_('This is the help text')) class MyThing(models.Model): name = models.CharField(_('name'), help_text=_('This is the help text')) class Meta: verbose_name = _('my thing') verbose_name_plural = _('mythings') Loading