summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-10-14 03:48:27 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-10-14 03:48:27 +0000
commited1c9b20466324b085fb055b28c515ea3443e2a9 (patch)
tree72d3cff4bf1168a8291baa295173402867970568 /django
parentf2088d456c4ca394f59d179e990c6e611e92ff5f (diff)
Fixed #622 -- Added default_if_none filter. Thanks, Eric
git-svn-id: http://code.djangoproject.com/svn/django/trunk@859 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/defaultfilters.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/core/defaultfilters.py b/django/core/defaultfilters.py
index eb3ec11c95..42b46d03ea 100644
--- a/django/core/defaultfilters.py
+++ b/django/core/defaultfilters.py
@@ -333,6 +333,12 @@ def default(value, arg):
"If value is unavailable, use given default"
return value or arg
+def default_if_none(value, arg):
+ "If value is None, use given default"
+ if value is None:
+ return arg
+ return value
+
def divisibleby(value, arg):
"Returns true if the value is devisible by the argument"
return int(value) % int(arg) == 0