diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2007-02-23 18:02:51 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2007-02-23 18:02:51 +0000 |
| commit | 36512d5d734feee53b7787dbdf2d671f158ebaae (patch) | |
| tree | 930fe77de1c9d5b5bc84ec1c1bf4ff6dd89bb489 /docs/templates_python.txt | |
| parent | 1266766da4a30460a92659c270fea0904ce43c51 (diff) | |
Fixed #343: filters that take strings now handle non-strings correctly. Thanks to Boffbowsh for the original patch, and to SmileyChris for the updated patch and tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4558 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/templates_python.txt')
| -rw-r--r-- | docs/templates_python.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/templates_python.txt b/docs/templates_python.txt index a6b565ed5c..b6bfe67da2 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -654,6 +654,16 @@ decorator instead:: If you leave off the ``name`` argument, as in the second example above, Django will use the function's name as the filter name. +Template filters which expect strings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you are writing a template filter which only expects a string as the first +argument, you should use the included decorator ``to_str`` which will convert +an object to it's string value before being passed to your function:: + + def lower(value): + return value.lower() + lower = template.to_str(lower) + Writing custom template tags ---------------------------- |
