After upgrading to 1.6 yesterday, our production instance is exhibiting some odd behaviour with prefetch_related.
As the example below shows, when using prefetch_related on the foreign field (viewed_cm), the returned instance apparently does not have this foreign field set, even though the earlier filter on the queryset asserted it had to exist.
>>> cb = user.coursebookmark_set.filter(viewed_cm__course__type=course_type).prefetch_related('viewed_cm').latest('viewed_at')
>>> cb.viewed_cm
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/ubuntu/app/ve-web/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 314, in __get__
DoesNotExist: CourseBookmark has no viewed_cm.
>>>
When prefetch_related is excluded, everything operates as expected.
>>> cb = user.coursebookmark_set.filter(viewed_cm__course__type=course_type).latest('viewed_at')
>>> cb.viewed_cm
<CourseModule: py3-intro-calculating-things in intro-python-1>
>>>
Has anyone else experienced anything like this before? I can't seem to replicate it not on production.