I’m a bit stuck on how to display the titles for 2 pages that list articles of different categories using the same template. My article models have content, category (sport, politics, tech etc) and status. I want to display a page listing all sport articles and a page listing politics and I want to use the same template. I have tried storing the title as a variable in the view but this doesn't work
Views.py
def sport_landing(request):
page_title = 'Sport'
cat_landing = Article.objects.filter(status='published', category='sport', published_date__lte=timezone.now()
).order_by('-published_date')
return render(request, "categorylanding.html", {'cat_landing': cat_landing}
Template
{% extends 'base.html' %}
{% load humanize %}
{% block content %}
<div class="row category-landing-title">
<div class="col-xs-12">
{% page_title %}
</div>
</div>
.
.
.
Is this even the best way to do this?