Last active
December 27, 2015 20:09
-
-
Save loic/7382392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py | |
index 6299b20..577f503 100644 | |
--- a/django/db/models/fields/related.py | |
+++ b/django/db/models/fields/related.py | |
@@ -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' % self.field.related_field.name: 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