KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Model1 has a ForeignKey to Model2. And Model2 has a ForeignKey(Model3, null=True, blank=True) to Model3. By default, when I use select_related() on Model1, Model3 is not selected because of null=True. How can I force select_related() to follow a foreign_key that has has null=True? The only way I can think of is to explicitly select these foreign keys: model1s = Model1.objects.all().select_related('model2', 'model2__model3') Is this the only way?
Tags (comma-separated)
Save Edits
Cancel