如何在 django cms 页面中显示 django 无尽的分页?目前我正在使用模板标签呈现我的内容(图像)。是否可以在模板标签中编写分页代码?我的 cms 模板是:
{% extends 'base.html' %}
{% load cms_tags sekizai_tags instagram_images media_list %}
{% block title %}Home{% endblock %}
{% block main_content %}
<section class="bigBanner clearfix">
<div class="container "> </div>
</section>
</div>
</section>
<hgroup class="title">
<div class="container ">
<h1>Videos</h1>
</div>
</hgroup>
<section class="clearfix content innerPage galleyPage">
{% get_video_gallery %}
<hgroup class="title">
<div class="container ">
<h1>Images</h1>
</div>
</hgroup>
<div class="container">
{% get_photo_gallery %}
</div>
</section>
{% endblock %}
我的 get_photo_gallery 模板标签是:
@register.inclusion_tag('cms/templatetags/image_gallery.html')
def get_photo_gallery():
try:
images = Images.objects.all()
except:
images = None
return {'images':images}
我的 image_gallery.html 是:
<div class="imageSelector">
Select a category : <select name="" class="selector">
<option>Events</option>
<option>Events</option>
<option>Events</option>
<option class="last">Events</option>
</select><input name="GO" type="submit" class="goBtn" id="GO" value="GO" />
</div>
{% for image in images %}
{% if forloop.counter|add:"-1"|divisibleby:"3" %}
<div class="clearfix row-fluid">
{% endif %}
<div class="span4">
<a class="gallery" href="{{ image.image.url }}" {% if LANGUAGE_BIDI %} title="{{ image.description_ar }}" {% else %} title="{{ image.description }}" {% endif %}>
<img src="{{ image.image.url }}" width="370 px" height="302px" alt="" /></a>
{% if LANGUAGE_BIDI %}
<p>{{ image.description_ar|truncatechars:17|safe }}</p>
{% else %}
<p>{{ image.description|truncatechars:17|safe }}</p>
{% endif %}
</div>
{% if forloop.counter|divisibleby:"3" %}
</div>
{% endif %}
{% endfor %}
我真正想要展示的是 twitter 风格的分页http://django-endless-pagination.readthedocs.org/en/latest/twitter_pagination.html。正常的分页是有效的,因为它唯一的模板更改为显示分页页面。但是 twitter 风格需要更改视图,并且不使用视图呈现 cms 页面模板。