Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Edited docs/templates_python.txt change from [6143]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e86d35879fa7b111d271dfab393a7691b90fca6c 1 parent 2bec822
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 docs/templates_python.txt
View
14 docs/templates_python.txt
@@ -642,12 +642,12 @@ your function. Example::
"Converts a string into all lowercase"
return value.lower()
-Template filters which expect strings
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Template filters that expect strings
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you're writing a template filter which only expects a string as the first
-argument, you should use the included decorator ``stringfilter``. This will
-convert an object to it's string value before being passed to your function::
+If you're writing a template filter that only expects a string as the first
+argument, you should use the decorator ``stringfilter``. This will
+convert an object to its string value before being passed to your function::
from django.template.defaultfilters import stringfilter
@@ -655,6 +655,10 @@ convert an object to it's string value before being passed to your function::
def lower(value):
return value.lower()
+This way, you'll be able to pass, say, an integer to this filter, and it
+won't cause an ``AttributeError`` (because integers don't have ``lower()``
+methods).
+
Registering a custom filters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please sign in to comment.
Something went wrong with that request. Please try again.