Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Many-to-One | Relations
Django ORM Ninja: Técnicas Avanzadas para Desarrolladores
course content

Contenido del Curso

Django ORM Ninja: Técnicas Avanzadas para Desarrolladores

Django ORM Ninja: Técnicas Avanzadas para Desarrolladores

1. Introduction to Django ORM
2. Models, datatypes, and fields
3. Queries
4. Relations
5. Complex Queries
6. Advanced

book
Many-to-One

A relational database is named for its structure, which includes relationships between different tables. The most common type is the Many-to-One relationship. For instance, a single reporter can write many articles, but each article has only one reporter. Similarly, a literary genre may be associated with many books, but each book belongs to only one genre.

Let's define this relationship between Book and Genre in Django models:

A ForeignKey field type links linking Book to the Genre model. This creates the Many-to-One relationship, where each book is related to one genre. The on_delete=models.CASCADE argument means that if a genre is deleted, all books in that genre will also be deleted.

1. En Django, ¿cómo se define una relación de Muchos-a-Uno entre dos modelos?
2. If a 'Book' model has a 'ForeignKey' linked to a 'Genre' model, what does this indicate about their relationship?
En Django, ¿cómo se define una relación de Muchos-a-Uno entre dos modelos?

En Django, ¿cómo se define una relación de Muchos-a-Uno entre dos modelos?

Selecciona la respuesta correcta

If a 'Book' model has a 'ForeignKey' linked to a 'Genre' model, what does this indicate about their relationship?

If a 'Book' model has a 'ForeignKey' linked to a 'Genre' model, what does this indicate about their relationship?

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 1
We're sorry to hear that something went wrong. What happened?
some-alt