mirror of
https://github.com/django/django.git
synced 2025-07-23 13:15:32 +00:00
Made ModelForms raise ImproperlyConfigured if the list of fields is not specified.
Also applies to modelform(set)_factory and generic model views. refs #19733.
This commit is contained in:
parent
1c8dbb0cc2
commit
ee4edb1eda
9 changed files with 77 additions and 100 deletions
|
@ -128,16 +128,15 @@ here; we don't have to write any logic ourselves::
|
|||
We have to use :func:`~django.core.urlresolvers.reverse_lazy` here, not
|
||||
just ``reverse`` as the urls are not loaded when the file is imported.
|
||||
|
||||
.. versionchanged:: 1.6
|
||||
The ``fields`` attribute works the same way as the ``fields`` attribute on the
|
||||
inner ``Meta`` class on :class:`~django.forms.ModelForm`. Unless you define the
|
||||
form class in another way, the attribute is required and the view will raise
|
||||
an :exc:`~django.core.exceptions.ImproperlyConfigured` exception if it's not.
|
||||
|
||||
In Django 1.6, the ``fields`` attribute was added, which works the same way as
|
||||
the ``fields`` attribute on the inner ``Meta`` class on
|
||||
:class:`~django.forms.ModelForm`.
|
||||
|
||||
Omitting the fields attribute will work as previously, but is deprecated and
|
||||
this attribute will be required from 1.8 (unless you define the form class in
|
||||
another way).
|
||||
.. versionchanged:: 1.8
|
||||
|
||||
Omitting the ``fields`` attribute was previously allowed and resulted in a
|
||||
form with all of the model's fields.
|
||||
|
||||
Finally, we hook these new views into the URLconf::
|
||||
|
||||
|
|
|
@ -430,13 +430,11 @@ In addition, Django applies the following rule: if you set ``editable=False`` on
|
|||
the model field, *any* form created from the model via ``ModelForm`` will not
|
||||
include that field.
|
||||
|
||||
.. versionchanged:: 1.6
|
||||
|
||||
Before version 1.6, the ``'__all__'`` shortcut did not exist, but omitting
|
||||
the ``fields`` attribute had the same effect. Omitting both ``fields`` and
|
||||
``exclude`` is now deprecated, but will continue to work as before until
|
||||
version 1.8
|
||||
.. versionchanged:: 1.8
|
||||
|
||||
In older versions, omitting both ``fields`` and ``exclude`` resulted in
|
||||
a form with all the model's fields. Doing this now raises an
|
||||
:exc:`~django.core.exceptions.ImproperlyConfigured` exception.
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue