Reputation: 1724
I have the following folder structure:
myProject
|
myapp
|
templatetags
| __init__.py
| app_tags.py
The app_tags.py file:
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.filter(is_safe=False)
@stringfilter
def upper2(value):
"""Converts a string into all uppercase."""
return value.upper()
The test.html template:
{% load app_tags % }
<div>Test Word: {{ test_word }}</div>
<div>Test Word: {{ test_word|upper2 }}</div>
If I use the {{ test_word|upper2 }}
I get an Invalid filter: 'upper2'
error.
If I don't try to use the upper2
filter, the {% load app_tags % }
doesn't appear to be loading.
Thanks for any help!
Upvotes: 0
Views: 386
Reputation: 1724
And... there was a white space in {% load app_tags % }
Once I changed the loading tag to {% load app_tags %}
, it worked great!
Upvotes: 1