| Name | dharani |
|---|---|
| Email Address | n/a |
| Posts | 2 |
-
- 2010-08-23 05:44:19
- Re: TemplateSyntaxError
- Board » Django » Templates
-
Thank you very much my friend.. Its working now.
-
- 2010-08-20 09:03:45
- TemplateSyntaxError
- Board » Django » Templates
-
Hello All,
I am trying to create a custom template filters.
The error that I got was 'Filters' is not a valid tag library
This is how my directory looks
Project1 /
App1/
settings.py
urls.py
manage.py
.
.
App1/
templatetags/
__init__.py
Filters.py
views.py
models.py
.....
My Settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
'Project1.App1.templatetags',
)
I included the path 'Project1.App1.templatetags' to the INSTALLED_APP tuple.
I registed the Filters.py and this how it looks
Filters.py
----------------------------------------------------
from django.template import Library
register = Library()
@register.filter(name='cut')
def cut(value, arg):
return value.replace(arg, '')
@register.filter
def lower123(value):
return value.lower()
------------------------------------------------------
A simple filter tag
And this was the error that i got!
Template error
'Filters' is not a valid tag library: Template library Filters not found, tried django.templatetags.Filters,django.contrib.admin.templatetags.Filters
1 <html>
2 {%load Filters %}
3 <h1><p>{{dharani}}</p></h1>
4 </html>
The error was in the second line..
Could someone please help me sort this out!
Cheers..


