Django Forms Course

Go to class
Write Review

Free Online Course: Django Forms Course provided by Treehouse is a comprehensive online course, which lasts for 4-5 hours worth of material. The course is taught in English and is free of charge.

Overview
  • Django Forms let us quickly create HTML forms and validate information from users and APIs. Django gives us two types of Forms, basic Forms and Model Forms, which turn our Models into Forms. Our learning app needs quizzes, so let's build them with Forms!

    What you'll learn

    • Forms
    • Model Forms
    • Data validation
    • Model inheritance

Syllabus
  • Forms

    Basic Forms in Django are handy for data validation and non-model-based data entry. They automatically create their own HTML and do some serious validation.

    Chevron 13 steps
    • What are Forms in Django?

      1:58

    • Creating a Form

      4:04

    • Create a Simple Form

      4 objectives

    • Showing a Form in a View

      8:18

    • Instantiate a Form in a View

      3 objectives

    • Handling a Form in a View

      10:10

    • Validate a Form in a View

      2 objectives

    • Custom Field Validation

      7:16

    • Clean a Field

      2 objectives

    • Using and Creating Validators

      3:38

    • Create a Validator

      2 objectives

    • Cleaning a Whole Form

      4:28

    • Clean Two Fields

      1 objective

    More on Models

    To create our quizzes, we're going to need a few more models. And since a few of them share a lot of information and functionality, let's look into inheritance with multiple tables and abstract models.

    Chevron 7 steps
    • Abstract Inheritance

      7:13

    • Review: Models

      5 questions

    • Quiz Model

      10:10

    • Abstract Model

      2 objectives

    • Question and Answer Models

      6:28

    • Multiple Choice and True/False Questions

      3:53

    • Multi-table Inheritance

      2 objectives

    Model Forms

    Quite often, we just want a form that represents a model in our app. Django gives us a great way to handle that scenario with Model Forms.

    Chevron 10 steps
    • What are Model Forms?

      6:30

    • Create a Model Form

      1 objective

    • Using a Model Form

      10:22

    • Edit an Instance

      9:48

    • Display a Blank Model Form

      2 objectives

    • Handling Multiple Form Classes

      11:12

    • Editing Questions

      11:54

    • Save a Model Form

      1 objective

    • Model Form for Answer

      10:04

    • Review: Model Forms

      5 questions

    Inlines and Media

    Now that we have basic and model forms down, let's see how to use multiple forms, inline forms, and provide some special media to our forms.

    Chevron 7 steps
    • Formsets

      9:23

    • Create a Formset

      2 objectives

    • Save a Valid Formset

      1 objective

    • Inline Model Formset

      12:18

    • Create an Inline Model Formset

      2 objectives

    • Custom Form Media

      9:47

    • Review: Django Forms

      8 questions

    • Extra Credit

      Now that you have control of Django's forms, go back and build CMS-style views, forms, etc for the Text and Course models.