I'm building a webpage using wagtail CMS, Django, Postgresql and at the bottom of the page, I'm building a section where I would display the videos using pagination.
I'm trying to retrieve the data from Django Models using all_posts = MultiBlogPage.objects.values("all_blogs_content_pages")
and I'm getting the output as
<PageQuerySet [{'all_blogs_content_pages':
[
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ee2d21d0>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ed8fa2e8>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35f617e6a0>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ed90aac8>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ed90af60>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ed90a978>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ed90ae48>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ee2b9320>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ee2b9630>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ee339f28>,
<wagtail.core.blocks.stream_block.StreamValue.StreamChild object at 0x7f35ee339470>
]}]>
Could someone please look at my code below and let me know how to get the exact values from Django Models ?
def get_context(self, request, *args, **kwargs):
context = super(MultiBlogPage, self).get_context(request, *args, **kwargs)
context['multiblog_page'] = self
// The name of the stream field panel is "all_blogs_content_pages"
all_posts = MultiBlogPage.objects.values("all_blogs_content_pages")
print("all_posts...",all_posts)
paginator = Paginator(all_posts, 3)
print("paginator", paginator)
page = request.GET.get("page")
try:
posts = paginator.page(page)
except PageNotAnInteger:
posts = paginator.page(1)
except EmptyPage:
posts = paginator.page(paginator.num_pages)
context["posts"] = posts
return context
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…