Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Django Class-based Views Course

via Treehouse

This course may be unavailable.

Overview

Django view functions are simple and easy to use but sometimes you find yourself repeating a lot of the same work over and over. Luckily, Django also offers a way to create views as classes which can lead to cleaner, more reusable code. Class-based views have a lot of nooks and crannies, though, so let us show you around this powerful tool!

What you'll learn

  • Class-based views
  • Generic views
  • Mixins

Syllabus

Classy Views

Django class-based views are a great way to avoid repeating yourself. They provide a shortcut to common functionality but they're not the easiest thing to wrap your head around. Let me help you get a grip on this Django feature.

Chevron 9 steps
  • What are Class-based Views?

    2:22

  • The View Class

    7:27

  • Basic View

    3 objectives

  • TemplateView

    6:48

  • TemplateView

    3 objectives

  • ListView and DetailView

    6:48

  • List and Detail

    3 objectives

  • CRUD Views

    14:41

  • CRUDs

    3 objectives

Customizing Class-based Views

Class-based views wouldn't be nearly as useful if you couldn't tweak them to meet your needs. I'll show you how to combine view classes, use Django's provided mixins, and more to get just the view you need.

Chevron 9 steps
  • Overriding Methods

    8:01

  • Override get_queryset

    1 objective

  • Franken-Views

    6:30

  • Combine DetailView and DeleteView

    3 objectives

  • Mixins

    13:09

  • LoginRequiredMixin

    2 objectives

  • Custom Mixin

    4 objectives

  • Wrap Up

    0:51

  • Review: Django Class-based Views

    6 questions

Reviews

Start your review of Django Class-based Views Course

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.