I have problems with the use of select_related. I have two models where one model keeps language independent data, and the other keeps translations in various languages.
class Model() company = ForeignKey(Company, null=True, blank=True) def getCompanyName(self): return (self.company and self.company.name) or 'N/A' class ModelTrans() parent = ForeignKey(Model) language = ForeignKey(Language) Then I query on the translation table and use select_related to reduce the query count to 1: objs = ModelTrans.objects.filter(language__code = 'en').select_related('parent__company') for obj in objs: obj.parent.getCompanyName() I noticed a lot of queries to the database, started investigating and found that for every obj in the loop another query is made to the Company table, even though it is in select_related. Any idea why? Could this potentially be because the 'company' table gets read from the Model object and not from the ModelTrans object, from where it was queried? I make extensive use of select_related and would say that it works well in 90% of the cases, yet in some it's failing on me. I'm with Django 1.5. Thanks Joris -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/555B88C3.70801%40promani.be. For more options, visit https://groups.google.com/d/optout.