1👍
✅
You can get all of the runners in a race by doing:
self.runner_set.select_related('person')
This will contain all of the runners, and will have a JOIN
to the person table.
When you use .values()
, then it gives you back the foreign key values, which is not what you want.
If you want, you can use the related_name="runners"
within your foreign key to Race. Then you’ll be able to access it via self.runners...
Source:stackexchange.com