开发者

Using django-paging extension with Django and Jinja2/Coffin

开发者 https://www.devze.com 2023-01-14 06:59 出处:网络
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/In

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)

开发者_JS百科Any help is appreciated.


Ok, problem solved. The paging application should be added into INSTALLED_APPS (settings.py)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号