I want to add similar posts section to my blog django application in Class DetailView on detail page
class DetailView(generic.DetailView):
model = Deal
template_name = 'deals/detail.html'
I want to add similar posts section to my blog django application in Class DetailView on detail page
class DetailView(generic.DetailView):
model = Deal
template_name = 'deals/detail.html'
class DetailView(generic.DetailView):
model = Deal
template_name = 'deals/detail.html'
def get_context_data(self, **kwargs):
context = super().get_context_data()
context[post] = post
return context
get_context_data method is responsible for passing the data in template . the context is a dict so you and add your key value in this dict and access it form template.
<html>
<body>
{{post}}
</body>
</html>
what ever data you added it to your context dict the you can access it from template with key.