The form based on a model

ModelForms are Django forms based on models. The fields of these forms are automatically generated from the model that we have defined. Indeed, developers are often required to create forms with fields that correspond to those in the database to a non-MVC website.

These particular forms have a save() method that will save the form data in a new record.

The supervisor creation form

To broach, we will take, for example, the addition of a supervisor. For this, we will create a new page. For this, we will create the following URL:

url(r'^create-supervisor$', 'TasksManager.views.create_supervisor.page', name="create_supervisor"),

Our view will contain the following code:

from django.shortcuts import render from TasksManager.models ...

Get Django: Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.