django-endless-paginationのドキュメントを読むと、ちょうど@page_template()デコレータを使用して、Ajaxページング機能をクラスベースのビューに拡張できます。 。 私は時間のように使用するためのものデコレータを実装しようとしてきた:django-endless-paginationをListViewを拡張したカスタムCベースのビューで使用する
class ExtendedListView(ListView):
template_name = 'global_template.html'
@method_decorator(@page_template('path_to_updatable_content_only_template'))
def dispatch(self, *args, **kwargs):
return super(ExtendedListView, self).dispatch(*args, **kwargs)
ビュー関数の出力は、すべてのエラーをしませんが、私は別のページに移動するときには、ターゲットに「global_template」をロードし、デコレータで定義されたテンプレートではありません。
この実装が実際に機能しているかどうか知っていて、何か間違いを指摘してください、私はそれを正しい方法で使用してうれしく思います。
class ExtendedListView(ListView):
template_name='global_template_path'
'''
render_to_response ¿hack? so that i can render only the updatable DOM part template
'''
def render_to_response(self, context):
if self.request.is_ajax():
self.template_name = 'path_to_updatable_content_only_template'
return super(ExtendedListView, self).render_to_response(context)
else:
return super(ExtendedListView, self).render_to_response(context)
乾杯:この同じ問題を持って、あなたがこれを行うことができ、このへの適合答えはありませんsomeoeneのので、もし
私はworkarroundを思い付くことができました! book.htmlで
# views.py
from endless_pagination.views import AjaxListView
class BookView(AjaxListView):
context_object_name = "books"
model = Book
template_name = 'books.html'
page_template = 'books_list.html'
:
私の問題は、複数のページネーションを動作させることです。 – acjay