diff options
author | 2020-10-30 19:12:41 +0200 | |
---|---|---|
committer | 2020-10-30 19:12:41 +0200 | |
commit | 29446162799358d751d3da9f9aee4ee8ae0b4496 (patch) | |
tree | 1a6e646c32d9f97857351e4f19829a3772a60274 /pydis_site/apps/content/views/articles.py | |
parent | Use Django URL generation for category URL (diff) |
Port views to TemplateView for content app
Diffstat (limited to 'pydis_site/apps/content/views/articles.py')
-rw-r--r-- | pydis_site/apps/content/views/articles.py | 18 |
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 |