擅长:python、mysql、java
<p>一。您是否将包含筛选器的文件放在应用程序的<code>templatetags</code>模块中?一、 你应该有这样的结构:</p>
<pre><code>project/
my_app/
templatetags/
__init__.py # Important! It makes templatetags a module. You can put your filters here, or in another file.
apptags.py # Or just put them in __init__.py
</code></pre>
<p>2。包括标签了吗?你需要像</p>
<pre><code>{% load apptags %}
</code></pre>
<p>在你的模板中。</p>