summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWoLpH <Rick@Fawo.nl>2012-11-22 22:29:39 +0100
committerWoLpH <Rick@Fawo.nl>2012-11-22 22:29:39 +0100
commiteabb44417ce1842007719b4b9378acca0e668b45 (patch)
tree0d84e9db5d7b43a97d78834e4d496d19540827ab
parent0e3690d2309e64ce7b7ae4938d41544c25f29870 (diff)
downloaddjango-eabb44417ce1842007719b4b9378acca0e668b45.tar.gz
changed if statement to a slightly cleaner/less confusing variant
-rw-r--r--docs/topics/db/models.txt7
1 files changed, 4 insertions, 3 deletions
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt
index 84b4c84061..2f1676ac1a 100644
--- a/docs/topics/db/models.txt
+++ b/docs/topics/db/models.txt
@@ -673,11 +673,12 @@ For example, this model has a few custom methods::
def baby_boomer_status(self):
"Returns the person's baby-boomer status."
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):
return "Pre-boomer"
- return "Post-boomer"
+ elif self.birth_date < datetime.date(1965, 1, 1):
+ return "Baby boomer"
+ else:
+ return "Post-boomer"
def is_midwestern(self):
"Returns True if this person is from the Midwest."