Ticket #2143: doc_api_fix.2.diff
File doc_api_fix.2.diff, 3.0 KB (added by , 18 years ago) |
---|
-
db-api.txt
559 559 # ... 560 560 hometown = models.ForeignKey(City) 561 561 562 class Book(m eta.Model):562 class Book(models.Model): 563 563 # ... 564 564 author = models.ForeignKey(Person) 565 565 -
i18n.txt
133 133 134 134 from django.utils.translation import gettext_lazy 135 135 136 class MyThing(m eta.Model):137 name = m eta.CharField(help_text=gettext_lazy('This is the help text'))136 class MyThing(models.Model): 137 name = models.CharField(help_text=gettext_lazy('This is the help text')) 138 138 139 139 In this example, ``gettext_lazy()`` stores a lazy reference to the string -- 140 140 not the actual translation. The translation itself will be done when the string … … 145 145 146 146 from django.utils.translation import gettext_lazy as _ 147 147 148 class MyThing(m eta.Model):149 name = m eta.CharField(help_text=_('This is the help text'))148 class MyThing(models.Model): 149 name = models.CharField(help_text=_('This is the help text')) 150 150 151 151 Always use lazy translations in `Django models`_. And it's a good idea to add 152 152 translations for the field names and table names, too. This means writing … … 155 155 156 156 from django.utils.translation import gettext_lazy as _ 157 157 158 class MyThing(m eta.Model):159 name = m eta.CharField(_('name'), help_text=_('This is the help text'))158 class MyThing(models.Model): 159 name = models.CharField(_('name'), help_text=_('This is the help text')) 160 160 class Meta: 161 161 verbose_name = _('my thing') 162 162 verbose_name_plural = _('mythings') -
forms.txt
15 15 because much of the time you won't need to use the lower-level APIs. Throughout 16 16 this document, we'll be working with the following model, a "place" object:: 17 17 18 from django.db import models 19 18 20 PLACE_TYPES = ( 19 21 (1, 'Bar'), 20 22 (2, 'Restaurant'), … … 22 24 (4, 'Secret Hideout'), 23 25 ) 24 26 25 class Place(m eta.Model):26 name = m eta.CharField(maxlength=100)27 address = m eta.CharField(maxlength=100, blank=True)28 city = m eta.CharField(maxlength=50, blank=True)29 state = m eta.USStateField()30 zip_code = m eta.CharField(maxlength=5, blank=True)31 place_type = m eta.IntegerField(choices=PLACE_TYPES)27 class Place(models.Model): 28 name = models.CharField(maxlength=100) 29 address = models.CharField(maxlength=100, blank=True) 30 city = models.CharField(maxlength=50, blank=True) 31 state = models.USStateField() 32 zip_code = models.CharField(maxlength=5, blank=True) 33 place_type = models.IntegerField(choices=PLACE_TYPES) 32 34 33 35 class Admin: 34 36 pass