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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user