mirror of https://github.com/django/django.git
[1.5.X] Changed if statement to a slightly cleaner variant
Backport of eabb44417c
from master
This commit is contained in:
parent
c90156fc18
commit
f88319dc3c
|
@ -673,10 +673,11 @@ For example, this model has a few custom methods::
|
||||||
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):
|
|
||||||
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"
|
||||||
|
elif self.birth_date < datetime.date(1965, 1, 1):
|
||||||
|
return "Baby boomer"
|
||||||
|
else:
|
||||||
return "Post-boomer"
|
return "Post-boomer"
|
||||||
|
|
||||||
def is_midwestern(self):
|
def is_midwestern(self):
|
||||||
|
|
Loading…
Reference in New Issue