In case this kind of issue ends up hitting anyone else, the bug was with 
django-cache-machine <https://github.com/jbalogh/django-cache-machine> not 
playing nicely with the Django cache API changes introduced in 
1.6<https://docs.djangoproject.com/en/dev/releases/1.6/#miscellaneous>
.

https://github.com/jbalogh/django-cache-machine/pull/48


On Saturday, 9 November 2013 11:23:21 UTC+11, Tim Dawborn wrote:
>
> 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__
>     "%s has no %s." % (self.field.model.__name__, self.field.name))
> 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.
>
>

-- 
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/f1a74f44-d57b-4205-97ab-768c34371fee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to