내가 블로그 게시물을 렌더링 작은 플라스크 응용 프로그램이 있습니다플라스크 mongoengine 페이지 매김
views.py :
class ListView(MethodView):
def get(self, page=1):
posts = Post.objects.all()
return render_template('posts/list.html', posts=posts)
이 모든 좋은,하지만 난 posts
객체에 페이지 매김을 추가하고 싶습니다 . project docs을 보면 페이지 매김 클래스가 있다는 것을 알았습니다.
class ListView(MethodView):
def get(self, page=1):
posts = Post.objects.paginate(page=page, per_page=10)
return render_template('posts/list.html', posts=posts)
을하지만 지금은 오류 얻을 :를 통해 내가 반복 어떻게 그래서
TypeError: 'Pagination' object is not iterable
을 내 템플릿에 posts
을?
도움을 주시면 감사하겠습니다.
임시 직원 늦은 코드? 공유 할 수 있습니까? – codegeek