Hi Anss, thanks for the reply. The queries are identical.
That's the exact reason I posted. Those two examples should essentially be the same, save for some sort of operator overloading. My note at the bottom about providing an empty list instead of the related cache when calling ``prefetch_related_objects`` implies that something weird is going on with the related cache, and the fact that it only happens when using the test client (at least, thus far) makes me think that it could possibly even be related to some sort of ``threading.local``, or something to that effect. The models are simple (named according to the example in the original post): class Foo(models.Model): title = models.CharField(max_length=255) class Baz(models.Model): name = models.CharField(max_length=255) class Bar(models.Model): foo = models.ForeignKey('Foo') baz = models.ForeignKey('Baz') quantity = models.IntegerField() My wild guesses: > - some sort of state leak in testing > - non-deterministic bug in prefetch_related (likely caused by random > ordering of the rows in the resultset) > > I hope you can provide us more data about this situation, > - Anssi > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/SirWYaLJLs4J. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.