Saving the foreign key

We have already recorded data from a model, but so far, we have never recorded it in the relationship database. The following is an example of recording a relationship that we will explain later in the chapter:

from TasksManager.models import Project, Task, Supervisor, Developer from django.shortcuts import render from django.utils import timezone def page(request): # Saving a new supervisor new_supervisor = Supervisor(name="Guido van Rossum", login="python", password="password", last_connection=timezone.now(), email="python@python.com", specialisation="Python") # line 1 new_supervisor.save() # Saving a new developer new_developer = Developer(name="Me", login="me", password="pass", last_connection=timezone.now(), email="me@python.com", ...

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.