Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
One-to-One | Relations
Django ORM Ninja: Advanced Techniques for Developers

One-to-OneOne-to-One

A One-to-One relationship is used when one object of a model corresponds to exactly one object of another model. For example, a table of employees and another table of employee ID badges, where each employee has exactly one unique ID badge. To specify a One-to-One relation, use models.OneToOneField.

OneToOneField accepts all of the extra arguments accepted by ForeignKey.

There is just an example of usage One-to-One relations. We will not use it in our project.

You can learn more about this relation in the official documentation.

How can you access the related Badge object from an Employee instance named employee?

Select the correct answer

Everything was clear?

Section 4. Chapter 3
course content

Course Content

Django ORM Ninja: Advanced Techniques for Developers

One-to-OneOne-to-One

A One-to-One relationship is used when one object of a model corresponds to exactly one object of another model. For example, a table of employees and another table of employee ID badges, where each employee has exactly one unique ID badge. To specify a One-to-One relation, use models.OneToOneField.

OneToOneField accepts all of the extra arguments accepted by ForeignKey.

There is just an example of usage One-to-One relations. We will not use it in our project.

You can learn more about this relation in the official documentation.

How can you access the related Badge object from an Employee instance named employee?

Select the correct answer

Everything was clear?

Section 4. Chapter 3
some-alt