TemplateView and get_context_data
Render a template and add context cleanly.
Meet TemplateView
TemplateView is a generic CBV whose only job is to render a template. It is the simplest class-based view you will use.
Set template_name
You tell TemplateView which file to render with the template_name attribute. No get method needed for a plain page.
class AboutView(TemplateView):
template_name = "about.html"All lessons in this course
- From Function Views to View Classes
- TemplateView and get_context_data
- Handling get and post Methods
- Mixins and as_view()