我安装了一个名为 Django-notification 的应用程序,它使用 Django-pagination。但是,它找不到 Django_pagination 模板标签!
Exception Type: TemplateSyntaxError at /notifications
Exception Value: 'pagination_tags' is not a valid tag library: Template library pagination_tags not found, tried django.templatetags.pagination_tags,django.contrib.admin.templatetags.pagination_tags,django.contrib.humanize.templatetags.pagination_tags,pinax.templatetags.templatetags.pagination_tags
为什么?我已经安装了 Django 分页。它在我的站点包中:django_pagination-1.0.7-py2.6.egg
接下来,我将“分页”放入 INSTALLED_APPS 中。
我什至在我的views.py 中添加了分页。尽管我怀疑这会有所作为。
最佳答案
为了确定,您是否在模板中调用了 {% load pagination_tags %}
?
The app that contains the custom tags must be in INSTALLED_APPS in order for the {% load %} tag to work. This is a security feature: It allows you to host Python code for many template libraries on a single host machine without enabling access to all of them for every Django installation.
There's no limit on how many modules you put in the templatetags package. Just keep in mind that a {% load %} statement will load tags/filters for the given Python module name, not the name of the app.
To be a valid tag library, the module must contain a module-level variable named register that is a template.Library instance...
关于python - 我怎么会收到这个 Django 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4631820/