0PricingLogin
Django Academy · Lesson

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

  1. From Function Views to View Classes
  2. TemplateView and get_context_data
  3. Handling get and post Methods
  4. Mixins and as_view()
← Back to Django Academy