KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How to make "manual" select_related imitation to avoid undesirable DB hits? we have: class Country: name = CharField() class City: country = models.ForeignKey(Country) name = models.CharField() cities = City.objects.raw("select * from city inner join country on city.country_id = country.id where name = 'london'") #this will hill hit DB print cities[0].country.name How to tell django that related models are already fetched.
Tags (comma-separated)
Save Edits
Cancel