summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-01-16 06:44:23 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-01-16 06:44:23 +0000
commit1ca9e95d4e9ec5922ce6aee6c143006b6c551e48 (patch)
treebfb2bd36446db9e9ff37cff06f99a0a1d57a80d7 /docs
parent645eb2b26b01520d7e98cb3c2f671e254571a090 (diff)
Fixed #15062 -- Documented the fact that managers must be able to be shallow copied. Thanks to Ian Clelland for the report, and Łukasz Rekucki for the help diagnosing the problem.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15220 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/managers.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/topics/db/managers.txt b/docs/topics/db/managers.txt
index 9c5ed620ab..d9a144bd62 100644
--- a/docs/topics/db/managers.txt
+++ b/docs/topics/db/managers.txt
@@ -274,6 +274,28 @@ it into the inheritance hierarchy *after* the defaults::
# Default manager is CustomManager, but OtherManager is
# also available via the "extra_manager" attribute.
+Implementation concerns
+-----------------------
+
+Whatever features you add to your custom ``Manager``, it must be
+possible to make a shallow copy of a ``Manager`` instance; i.e., the
+following code must work::
+
+ >>> import copy
+ >>> manager = MyManager()
+ >>> my_copy = copy.copy(manager)
+
+Django makes shallow copies of manager objects during certain queries;
+if your Manager cannot be copied, those queries will fail.
+
+This won't be an issue for most custom managers. If you are just
+adding simple methods to your ``Manager``, it is unlikely that you
+will inadvertently make instances of your ``Manager`` uncopyable.
+However, if you're overriding ``__getattr__`` or some other private
+method of your ``Manager`` object that controls object state, you
+should ensure that you don't affect the ability of your ``Manager`` to
+be copied.
+
.. _manager-types:
Controlling automatic Manager types