aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/views/articles.py
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/content/views/articles.py')
-rw-r--r--pydis_site/apps/content/views/articles.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/pydis_site/apps/content/views/articles.py b/pydis_site/apps/content/views/articles.py
index cce601e1..d66425c3 100644
--- a/pydis_site/apps/content/views/articles.py
+++ b/pydis_site/apps/content/views/articles.py
@@ -2,17 +2,19 @@ from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse
from django.shortcuts import render
from django.views import View
+from django.views.generic import TemplateView
from pydis_site.apps.content.utils import get_articles, get_categories
-class ArticlesView(View):
+class ArticlesView(TemplateView):
"""Shows all content and categories."""
- def get(self, request: WSGIRequest) -> HttpResponse:
- """Shows all content and categories."""
- return render(
- request,
- "content/articles.html",
- {"content": get_articles(), "categories": get_categories()}
- )
+ template_name = "content/articles.html"
+
+ def get_context_data(self, **kwargs):
+ """Add articles and categories data to template context."""
+ context = super().get_context_data(**kwargs)
+ context["content"] = get_articles()
+ context["categories"] = get_categories()
+ return context