summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2013-10-15 04:22:34 -0700
committerMarc Tamlyn <marc.tamlyn@gmail.com>2013-10-15 04:22:34 -0700
commitce823d37109208644ec8a9acf2dfa915c73c42eb (patch)
treeee633a34de063fe3bd61cd217b564753df0eb9e9 /docs
parented8919cbcb83302ea71572f5c7d5e6796bb21afa (diff)
parentb16dd1fe019b38d0dcdf4a400e9377fb06b33178 (diff)
Merge pull request #1382 from loic/ticket19617
Fixed #19617 -- Refactored form metaclasses to support more inheritance scenarios.
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/deprecation.txt2
-rw-r--r--docs/ref/forms/api.txt7
-rw-r--r--docs/releases/1.7.txt14
-rw-r--r--docs/topics/forms/modelforms.txt23
4 files changed, 42 insertions, 4 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index a965627a1c..b584a28ba1 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -467,6 +467,8 @@ these changes.
* The ``use_natural_keys`` argument for ``serializers.serialize()`` will be
removed. Use ``use_natural_foreign_keys`` instead.
+* ``django.forms.get_declared_fields`` will be removed.
+
2.0
---
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index 14092512dc..c15f748308 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -854,6 +854,13 @@ classes::
<li>Instrument: <input type="text" name="instrument" /></li>
<li>Haircut type: <input type="text" name="haircut_type" /></li>
+.. versionadded:: 1.7
+
+* It's possible to opt-out from a ``Field`` inherited from a parent class by
+ shadowing it. While any non-``Field`` value works for this purpose, it's
+ recommended to use ``None`` to make it explicit that a field is being
+ nullified.
+
.. _form-prefix:
Prefixes for forms
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index 7a49f13327..5c208e22ac 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -288,6 +288,14 @@ Forms
:func:`~django.forms.formsets.formset_factory` to allow validating
a minimum number of submitted forms.
+* The metaclasses used by ``Form`` and ``ModelForm`` have been reworked to
+ support more inheritance scenarios. The previous limitation that prevented
+ inheriting from both ``Form`` and ``ModelForm`` simultaneously have been
+ removed as long as ``ModelForm`` appears first in the MRO.
+
+* It's now possible to opt-out from a ``Form`` field declared in a parent class
+ by shadowing it with a non-``Field`` value.
+
Internationalization
^^^^^^^^^^^^^^^^^^^^
@@ -513,6 +521,12 @@ Miscellaneous
still worked, even though it was not documented or officially supported. If
you're still using it, please update to the current :setting:`CACHES` syntax.
+* The default ordering of ``Form`` fields in case of inheritance has changed to
+ follow normal Python MRO. Fields are now discovered by iterating through the
+ MRO in reverse with the topmost class coming last. This only affects you if
+ you relied on the default field ordering while having fields defined on both
+ the current class *and* on a parent ``Form``.
+
Features deprecated in 1.7
==========================
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index c65c705a58..2a48aa75dc 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -644,11 +644,24 @@ There are a couple of things to note, however.
used. This means the child's ``Meta``, if it exists, otherwise the
``Meta`` of the first parent, etc.
-* For technical reasons, a subclass cannot inherit from both a ``ModelForm``
- and a ``Form`` simultaneously.
+.. versionchanged:: 1.7
-Chances are these notes won't affect you unless you're trying to do something
-tricky with subclassing.
+* It's possible to inherit from both ``Form`` and ``ModelForm`` simultaneuosly,
+ however, you must ensure that ``ModelForm`` appears first in the MRO. This is
+ because these classes rely on different metaclasses and a class can only have
+ one metaclass.
+
+.. versionadded:: 1.7
+
+* It's possible to opt-out from a ``Field`` inherited from a parent class by
+ shadowing it. While any non-``Field`` value works for this purpose, it's
+ recommended to use ``None`` to make it explicit that a field is being
+ nullified.
+
+ You can only use this technique to opt out from a field defined declaratively
+ by a parent class; it won't prevent the ``ModelForm`` metaclass from generating
+ a default field. To opt-out from default fields, see
+ :ref:`controlling-fields-with-fields-and-exclude`.
.. _modelforms-factory:
@@ -748,6 +761,8 @@ instances of the model, you can specify an empty QuerySet::
>>> AuthorFormSet(queryset=Author.objects.none())
+.. _controlling-fields-with-fields-and-exclude:
+
Controlling which fields are used with ``fields`` and ``exclude``
-----------------------------------------------------------------