We studied the basics of the models that allow us to create simple applications. Sometimes, it is necessary to define more complex structures.
Sometimes, it is useful to store two foreign keys (or more) in a single model. For example, if we want two developers to work in parallel on the same task, we must use the related_name
property in our models. For example, our Task
model contains two relationships with the following lines:
developer1 = models.ForeignKey (Developer , verbose_name = "User" , related_name = "dev1" ) developer2 = models.ForeignKey (Developer , verbose_name = "User" , related_name = "dev2" )
Further in this book, we will not use these two relationships. To effectively follow this book, we must return to our previously defined Task
model.