[Answer]-Getting 'text' content from all pages rendered in Django

1👍

Your problem is trying to use two return statements:

return render(request, 'site_2015/page.html', {'page': pages})
#The second will not get rendered, and content will not be available
return render(request, 'site_2015/page.html', {'content': page})

Instead, you want to render the dictionary as a whole

return render(request, 'site_2015/page.html', {'page': pages, 'content' : page })

And then in your template

<div class="content">
  {{ content.text }}
</div>

The context variable content will now be directly available in your template.

👤C.B.

Leave a comment