If I remove the {% load  myfilters %} line from the template, the view
function gets called, and renders correctly. SO the view function is
found, and the template located by the view function. This error only
comes if I have {% load  myfilters %} line in the template.

My installed apps is,
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'test2.test'
)

urls.py
urlpatterns = patterns('test.views',
    # Example:
    # (r'^test2/', include('test2.foo.urls')),
    (r'^$','index'),

the index function is being called.

On Jan 16, 9:54 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Jan 16, 2008 11:31 AM, shabda <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > I want to use some custom filters, and so I am using the steps given
> > at
> >http://www.djangoproject.com/documentation/templates_python/#writing-...
>
> > What I did was,
> > 1. Created a templatetags directory under th app and created
> > __init__.py, myfilters.py under it. Its structure is like,
> > app/
> >  view.py
> >  models.py
> >  templatetags/myfilters.py
> >  templatetags/__init__.py
>
> > 2. added the app to installed app.
> > 3. Wrote something like this to myfilters.py
>
> > from django.template.defaultfilters import stringfilter
> > from django.template import Variable, Library
>
> > register = Library()
>
> > @register.filter(name='captalise')
> > @stringfilter
> > def capitalise(val, args):
> >    first, rest = val[0], val[1:]
> >    return first.to_upper() + rest
>
> > I want to use this filter in the template, and am doing
>
> > {% load myfilters %}
>
> > hello {{foo}}
>
> > This gives me a
> > TemplateSyntaxError at /
> > 'myfilters' is not a valid tag library: Could not load template
> > library from django.templatetags.myfilters, No module named myfilters
>
> > Stacktrace,
>
> > Traceback:
> > File "C:\Python24\lib\site-packages\django\core\handlers\base.py" in
> > get_response
> >  73.             callback, callback_args, callback_kwargs =
> > resolver.resolve(request.path)
> > File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> > resolve
> >  233.                     sub_match = pattern.resolve(new_path)
> > File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> > resolve
> >  172.             return self.callback, args, kwargs
> > File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> > _get_callback
> >  184.             raise ViewDoesNotExist, "Tried %s in module %s.
> > Error was: %s" % (func_name, mod_name, str(e))
>
> > What am I missing?
>
> I'm confused by your traceback; I would have expected a
> TemplateDoesNotExist, not a ViewDoesNotExist, to be the result of running
> into trouble loading a custom tag library.  What exactly do you have in
> INSTALLED_APPS and urls.py?
>
> Karen
>
> p.s. You should not need to put "__all__ = ['myfilters']" into your
> __init__.py for your templatetags directory.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to