Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.X] Changed if statement to a slightly cleaner variant

Backport of eabb444 from master
  • Loading branch information...
commit f88319dc3cd5a4a032e539f468dc118cb5fa9872 1 parent c90156f
@WoLpH WoLpH authored timgraham committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 docs/topics/db/models.txt
View
7 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."
Please sign in to comment.
Something went wrong with that request. Please try again.