mirror of
https://github.com/django/django.git
synced 2025-07-23 05:05:17 +00:00
Fixed #8620 -- Updated the Form metaclass to support excluding fields by shadowing them.
This commit is contained in:
parent
ac5ec7b8bc
commit
b16dd1fe01
5 changed files with 52 additions and 0 deletions
|
@ -651,6 +651,18 @@ There are a couple of things to note, however.
|
|||
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:
|
||||
|
||||
ModelForm factory function
|
||||
|
@ -749,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``
|
||||
-----------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue