Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[1.6.x] Fixed #22412 -- More nuanced advice re template filters and e…


Thanks Tim for review.

Backport of 7e3834a from master
  • Loading branch information...
1 parent e68c084 commit 728fd27c005e98868a3be74949f306038e30e427 @carljm carljm committed with timgraham
Showing with 5 additions and 3 deletions.
  1. +5 −3 docs/howto/custom-template-tags.txt
8 docs/howto/custom-template-tags.txt
@@ -87,9 +87,11 @@ Custom filters are just Python functions that take one or two arguments:
For example, in the filter ``{{ var|foo:"bar" }}``, the filter ``foo`` would be
passed the variable ``var`` and the argument ``"bar"``.
-Filter functions should always return something. They shouldn't raise
-exceptions. They should fail silently. In case of error, they should return
-either the original input or an empty string -- whichever makes more sense.
+Usually any exception raised from a template filter will be exposed as a server
+error. Thus, filter functions should avoid raising exceptions if there is a
+reasonable fallback value to return. In case of input that represents a clear
+bug in a template, raising an exception may still be better than silent failure
+which hides the bug.
Here's an example filter definition:

0 comments on commit 728fd27

Please sign in to comment.
Something went wrong with that request. Please try again.