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