Fixed #1773 -- Fixed indentation error in docs/model-api.txt. Thanks, pb

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2849 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-05-05 18:31:16 +00:00
parent a0872543a7
commit 3f932e31dc
1 changed files with 15 additions and 15 deletions

View File

@ -1484,23 +1484,23 @@ For example, this model has a few custom methods::
city = models.CharField(maxlength=50) city = models.CharField(maxlength=50)
state = models.USStateField() # Yes, this is America-centric... state = models.USStateField() # Yes, this is America-centric...
def baby_boomer_status(self): def baby_boomer_status(self):
"Returns the person's baby-boomer status." "Returns the person's baby-boomer status."
import datetime import datetime
if datetime.date(1945, 8, 1) <= self.birth_date <= datetime.date(1964, 12, 31): if datetime.date(1945, 8, 1) <= self.birth_date <= datetime.date(1964, 12, 31):
return "Baby boomer" return "Baby boomer"
if self.birth_date < datetime.date(1945, 8, 1): if self.birth_date < datetime.date(1945, 8, 1):
return "Pre-boomer" return "Pre-boomer"
return "Post-boomer" return "Post-boomer"
def is_midwestern(self): def is_midwestern(self):
"Returns True if this person is from the Midwest." "Returns True if this person is from the Midwest."
return self.state in ('IL', 'WI', 'MI', 'IN', 'OH', 'IA', 'MO') return self.state in ('IL', 'WI', 'MI', 'IN', 'OH', 'IA', 'MO')
def _get_full_name(self): def _get_full_name(self):
"Returns the person's full name." "Returns the person's full name."
return '%s %s' % (self.first_name, self.last_name) return '%s %s' % (self.first_name, self.last_name)
full_name = property(_get_full_name) full_name = property(_get_full_name)
The last method in this example is a *property*. `Read more about properties`_. The last method in this example is a *property*. `Read more about properties`_.