Ticket #2143: doc_api_fix.2.diff

File doc_api_fix.2.diff, 3.0 KB (added by mssnlayam@…, 9 years ago)

Fixes the API used in files in docs/

  • db-api.txt

     
    559559        # ...
    560560        hometown = models.ForeignKey(City)
    561561
    562     class Book(meta.Model):
     562    class Book(models.Model):
    563563        # ...
    564564        author = models.ForeignKey(Person)
    565565
  • i18n.txt

     
    133133
    134134    from django.utils.translation import gettext_lazy
    135135
    136     class MyThing(meta.Model):
    137         name = meta.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'))
    138138
    139139In this example, ``gettext_lazy()`` stores a lazy reference to the string --
    140140not the actual translation. The translation itself will be done when the string
     
    145145
    146146    from django.utils.translation import gettext_lazy as _
    147147
    148     class MyThing(meta.Model):
    149         name = meta.CharField(help_text=_('This is the help text'))
     148    class MyThing(models.Model):
     149        name = models.CharField(help_text=_('This is the help text'))
    150150
    151151Always use lazy translations in `Django models`_. And it's a good idea to add
    152152translations for the field names and table names, too. This means writing
     
    155155
    156156    from django.utils.translation import gettext_lazy as _
    157157
    158     class MyThing(meta.Model):
    159         name = meta.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'))
    160160        class Meta:
    161161            verbose_name = _('my thing')
    162162            verbose_name_plural = _('mythings')
  • forms.txt

     
    1515because much of the time you won't need to use the lower-level APIs. Throughout
    1616this document, we'll be working with the following model, a "place" object::
    1717
     18    from django.db import models
     19
    1820    PLACE_TYPES = (
    1921        (1, 'Bar'),
    2022        (2, 'Restaurant'),
     
    2224        (4, 'Secret Hideout'),
    2325    )
    2426
    25     class Place(meta.Model):
    26         name = meta.CharField(maxlength=100)
    27         address = meta.CharField(maxlength=100, blank=True)
    28         city = meta.CharField(maxlength=50, blank=True)
    29         state = meta.USStateField()
    30         zip_code = meta.CharField(maxlength=5, blank=True)
    31         place_type = meta.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)
    3234
    3335        class Admin:
    3436            pass
Back to Top