Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7904: added support for a "use_for_related_fields" property on…

… managers. If True, the manager will be used for related object lookups instead of the "bare" QuerySet introduced bu [8107]. Patch from Justin Bronn.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8212 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 593810a5014ecaa28215839fb42f03df44a069d0 1 parent c768bc6
Jacob Kaplan-Moss authored August 05, 2008
9  django/db/models/fields/related.py
@@ -239,7 +239,14 @@ def __get__(self, instance, instance_type=None):
11  docs/model-api.txt
@@ -1507,6 +1507,17 @@ good idea to be careful in your choice of default manager, in order to
1507 1507
 avoid a situation where overriding of ``get_query_set()`` results in
1508 1508
 an inability to retrieve objects you'd like to work with.
1509 1509
 
  1510
+Using managers for related object access
  1511
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1512
+
  1513
+By default, Django uses a "bare" (i.e. default) manager when accessing related
  1514
+objects (i.e. ``choice.poll``). If this default isn't appropriate for your default manager, you can force Django to use a custom manager for related object attributes by giving it a ``use_for_related_fields`` property::
  1515
+
  1516
+    class MyManager(models.Manager)::
  1517
+        use_for_related_fields = True
  1518
+        
  1519
+        ...
  1520
+
1510 1521
 Model methods
1511 1522
 =============
1512 1523
 
17  tests/regressiontests/reverse_single_related/models.py
@@ -26,7 +26,7 @@ class Item(models.Model):
@@ -34,10 +34,21 @@ class Item(models.Model):

0 notes on commit 593810a

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