Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@loic /foo.diff
Last active Dec 27, 2015

diff --git a/django/db/models/fields/ b/django/db/models/fields/
index 6299b20..577f503 100644
--- a/django/db/models/fields/
+++ b/django/db/models/fields/
@@ -268,7 +268,7 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
rel_obj_attr = self.field.get_foreign_related_value
instance_attr = self.field.get_local_related_value
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
- query = {'%s__in' % self.field.related_query_name(): instances}
+ query = {'%s__in' % set([instance_attr(i)[0] for i in instances])}
qs = self.get_queryset(instance=instances[0]).filter(**query)
# Since we're going to assign directly in the cache,
# we must manage the reverse relation cache manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.