Django

Code

Changeset 6159

Show
Ignore:
Timestamp:
09/13/07 23:04:51 (1 year ago)
Author:
adrian
Message:

Edited docs/templates_python.txt change from [6143]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/templates_python.txt

    r6143 r6159  
    643643        return value.lower() 
    644644 
    645 Template filters which expect strings 
    646 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    647  
    648 If you're writing a template filter which only expects a string as the first 
    649 argument, you should use the included decorator ``stringfilter``. This will 
    650 convert an object to it's string value before being passed to your function:: 
     645Template filters that expect strings 
     646~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     647 
     648If you're writing a template filter that only expects a string as the first 
     649argument, you should use the decorator ``stringfilter``. This will 
     650convert an object to its string value before being passed to your function:: 
    651651 
    652652    from django.template.defaultfilters import stringfilter 
     
    655655    def lower(value): 
    656656        return value.lower() 
     657 
     658This way, you'll be able to pass, say, an integer to this filter, and it 
     659won't cause an ``AttributeError`` (because integers don't have ``lower()`` 
     660methods). 
    657661 
    658662Registering a custom filters