[Answer]-Django database efficient querysets on two models

1👍

This would have been easier to answer if you’d shown your models. But assuming owner is a ForeignKey from FinalModel to whatever model you want to get at the end, you can use the double-underscore syntax to do a JOIN:

obj = MyModel.objects.get(owner__slug=slug)

(Note you don’t need to specify exact, it’s the default.)

Leave a comment