Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17696 - Queryset prefetch_related() ignores using()

Thanks to simon29 for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17605 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3db5b0e48554ccc76becefb86b630c9cf72be9f1 1 parent 413e374
Luke Plant authored March 01, 2012
2  django/contrib/contenttypes/generic.py
@@ -321,7 +321,7 @@ def get_query_set(self):
321 321
                 return super(GenericRelatedObjectManager, self).get_query_set().using(db).filter(**self.core_filters)
322 322
 
323 323
         def get_prefetch_query_set(self, instances):
324  
-            db = self._db or router.db_for_read(self.model)
  324
+            db = self._db or router.db_for_read(self.model, instance=instances[0])
325 325
             query = {
326 326
                 '%s__pk' % self.content_type_field_name: self.content_type.id,
327 327
                 '%s__in' % self.object_id_field_name:
9  django/db/models/fields/related.py
@@ -239,7 +239,7 @@ def get_query_set(self, **db_hints):
@@ -322,7 +322,7 @@ def get_prefetch_query_set(self, instances):
@@ -461,7 +461,7 @@ def get_query_set(self):
@@ -543,8 +543,9 @@ def get_query_set(self):
89  tests/modeltests/prefetch_related/tests.py
@@ -483,3 +483,92 @@ def test_in_bulk(self):

0 notes on commit 3db5b0e

Please sign in to comment.
Something went wrong with that request. Please try again.