diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/api.txt | 18 | ||||
| -rw-r--r-- | docs/releases/1.7.txt | 4 | ||||
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 6 |
3 files changed, 18 insertions, 10 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 4cf8e7d828..4fef753172 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -964,10 +964,20 @@ classes:: .. 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. +* It's possible to declaratively remove a ``Field`` inherited from a parent + class by setting the name to be ``None`` on the subclass. For example:: + + >>> from django import forms + + >>> class ParentForm(forms.Form): + ... name = forms.CharField() + ... age = forms.IntegerField() + + >>> class ChildForm(ParentForm): + ... name = None + + >>> ChildForm().fields.keys() + ... ['age'] .. _form-prefix: diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 44ccd022b6..4c01659ba6 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -544,8 +544,8 @@ Forms 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. +* It's now possible to remove a field from a ``Form`` when subclassing by + setting the name to ``None``. * The new :meth:`~django.forms.Form.add_error()` method allows adding errors to specific form fields. diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 9cd0223ea4..bfee475b88 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -674,10 +674,8 @@ There are a couple of things to note, however. .. 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. +* It's possible to declaratively remove a ``Field`` inherited from a parent class by + setting the name to be ``None`` on the subclass. 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 |
