summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-06-07 17:04:58 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-06-07 17:05:51 -0700
commit6fd455adfcc85f6bd390bce784a1b5dfe5d610ea (patch)
treebbde7ef48977f036461e15a68addc9a3dcdd261e /docs/topics
parent250e2b422b4da93f38cd61319b9b3c9f422e6ede (diff)
Fixed #22436: More careful checking on method ref'ce serialization
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/migrations.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt
index 8a5359fec4..40ce520a03 100644
--- a/docs/topics/migrations.txt
+++ b/docs/topics/migrations.txt
@@ -491,11 +491,30 @@ Django can serialize the following:
- Any class reference
- Anything with a custom ``deconstruct()`` method (:ref:`see below <custom-deconstruct-method>`)
+Django can serialize the following on Python 3 only:
+
+- Unbound methods used from within the class body (see below)
+
Django cannot serialize:
- Arbitrary class instances (e.g. ``MyClass(4.3, 5.7)``)
- Lambdas
+Due to the fact ``__qualname__`` was only introduced in Python 3, Django can only
+serialize the following pattern (an unbound method used within the class body)
+on Python 3, and will fail to serialize a reference to it on Python 2::
+
+ class MyModel(models.Model):
+
+ def upload_to(self):
+ return "something dynamic"
+
+ my_file = models.FileField(upload_to=upload_to)
+
+If you are using Python 2, we recommend you move your methods for upload_to
+and similar arguments that accept callables (e.g. ``default``) to live in
+the main module body, rather than the class body.
+
.. _custom-deconstruct-method:
Adding a deconstruct() method