1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

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
This commit is contained in:
Adrian Holovaty
2005-10-14 03:48:27 +00:00
parent f2088d456c
commit ed1c9b2046
2 changed files with 50 additions and 40 deletions

View File

@@ -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