0 day streak
python / beginner
Snippet

Static Class-Based Views

TemplateView is a built-in generic view used for rendering a template. It is ideal for static pages that do not require complex logic.

snippet.py
python
1
2
3
4
from django.views.generic import TemplateView
class AboutPageView(TemplateView):
template_name = 'about.html'
django
Breakdown
1
class AboutPageView(TemplateView):
Defines a new view class that inherits from Django's TemplateView.
2
template_name = 'about.html'
Tells Django which template file should be used for this view.