Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Document new field API in release notes

  • Loading branch information...
commit 1d1cfd0bd8016358719a1e73117c811f02ca8c02 1 parent de64c4d
Andrew Godwin authored August 09, 2013

Showing 1 changed file with 27 additions and 0 deletions. Show diff stats Hide diff stats

  1. 27  docs/releases/1.7.txt
27  docs/releases/1.7.txt
@@ -57,6 +57,33 @@ but a few of the key features are:
57 57
   will still work, but that method name is deprecated and you should change
58 58
   it as soon as possible (nothing more than renaming is required).
59 59
 
  60
+New method on Field subclasses
  61
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62
+
  63
+To help power both schema migrations and composite keys, the Field API now
  64
+has a new required method: ``deconstruct()``.
  65
+
  66
+This method takes no arguments, and returns a tuple of four items:
  67
+
  68
+* ``name``: The field's attribute name on its parent model, or None if it is not part of a model
  69
+* ``path``: A dotted, Python path to the class of this field, including the class name.
  70
+* ``args``: Positional arguments, as a list
  71
+* ``kwargs``: Keyword arguments, as a dict
  72
+
  73
+These four values allow any field to be serialized into a file, as well as
  74
+allowing the field to be copied safely, both essential parts of these new features.
  75
+
  76
+This change should not affect you unless you write custom Field subclasses;
  77
+if you do, you may need to reimplement the ``deconstruct()`` method if your
  78
+subclass changes the method signature of ``__init__`` in any way. If your
  79
+field just inherits from a built-in Django field and doesn't override ``__init__``,
  80
+no changes are necessary.
  81
+
  82
+If you do need to override ``deconstruct()``, a good place to start is the
  83
+built-in Django fields (``django/db/models/fields/__init__.py``) as several
  84
+fields, including ``DecimalField`` and ``DateField``, override it and show how
  85
+to call the method on the superclass and simply add or remove extra arguments.
  86
+
60 87
 Calling custom ``QuerySet`` methods from the ``Manager``
61 88
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 89
 

0 notes on commit 1d1cfd0

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