Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango: Invalid filter
    text
    copied!<p>I got an article app and trying to make a custom filter, I have a directory called templatetags in article app, and a tags.py within that directory, here is the directory structure.</p> <pre><code>-manage.py(f) -settings.py(f) -articles(d) - templatetags(d) - tags.py(f) </code></pre> <p>On the templates, the articles have its own directory, all article templates extend from a base.html template, here is the template structure.</p> <pre><code>-base.html(f) -articles(d) -index.html(f) </code></pre> <p>I load the tags in base.html {% load tags %} and use the custom filter in index.html and got the invalid filter error.</p> <p><strong><em>tags.py</em></strong></p> <pre><code>from django import template from django.template.defaultfilters import stringfilter register = template.Library() @register.filter @stringfilter def space2Dash(s): return s.replace(' ', '_'); </code></pre> <p>I just can't figure out what I did wrong.</p> <p>edit: I changed the filter name to <code>abcfilter.py</code> and I have the article app loaded in my <code>settings.py</code></p> <p>articles/index.html</p> <pre><code> {% load abcfilter %} {{ "foo bar"|space2dash }} </code></pre> <p>the error:</p> <pre><code>Request Method: GET Request URL: http://localhost:8080/articles/ Django Version: 1.2.5 Exception Type: TemplateSyntaxError Exception Value: Invalid filter: 'space2dash' Exception Location: ***/lib/python2.7/django/template/__init__.py in find_filter, line 363 Python Executable: /usr/local/bin/python Python Version: 2.7.1 Server time: Sun, 10 Apr 2011 07:55:54 -0500 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload