将 django-paging 扩展与 Django 和 Jinja2/Coffin 一起使用
最近,我将模板引擎从默认切换为 Jinja2/Coffin。一切工作正常,但我在尝试使用 Django/Jinja2 django-paging (http://linux.softpedia.com/get/Internet/HTTP-WWW-/django-paging-58496.shtml) 扩展在我的项目中。
有一个如何在 Jinja 中使用此扩展的示例:
{% with paginate(request, my_queryset) as results %}
{{ results.paging }}
{% for result in results.objects %}
{{ result }}
{% endfor %}
{{ results.paging }}
{% endwith %}
简单地说,我不知道在哪里以及如何定义这个新标签分页以被 Jinja2 引擎识别。
我尝试将 is 放在 settings.py 中:
JINJA2_EXTENSIONS = (
'paging.helpers.paginate',
)
但出现错误:
paginate() takes at least 2 arguments (1 given)
感谢任何帮助。
Recently I switched my templating engine from default to Jinja2/Coffin. Everything works just fine but I'm having troubles trying to use Django/Jinja2 django-paging (http://linux.softpedia.com/get/Internet/HTTP-WWW-/django-paging-58496.shtml) extension in my project.
There is an example how to use this extension with Jinja:
{% with paginate(request, my_queryset) as results %}
{{ results.paging }}
{% for result in results.objects %}
{{ result }}
{% endfor %}
{{ results.paging }}
{% endwith %}
Simply, I don't know where and how to define this new tag paginate to be recognized by Jinja2 engine.
I tried to put is in settings.py as:
JINJA2_EXTENSIONS = (
'paging.helpers.paginate',
)
but the error is raised:
paginate() takes at least 2 arguments (1 given)
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,问题解决了。分页应用程序应添加到 INSTALLED_APPS (settings.py)
Ok, problem solved. The paging application should be added into INSTALLED_APPS (settings.py)