mirror of
https://github.com/django/django.git
synced 2025-11-01 12:25:37 +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
|
|
@ -6,6 +6,7 @@ from datetime import date
|
|||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import models
|
||||
from django.forms.models import (_get_foreign_key, inlineformset_factory,
|
||||
modelformset_factory, BaseModelFormSet)
|
||||
|
|
@ -131,6 +132,15 @@ class DeletionTests(TestCase):
|
|||
|
||||
|
||||
class ModelFormsetTest(TestCase):
|
||||
def test_modelformset_factory_without_fields(self):
|
||||
""" Regression for #19733 """
|
||||
message = (
|
||||
"Calling modelformset_factory without defining 'fields' or 'exclude' "
|
||||
"explicitly is prohibited."
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, message):
|
||||
modelformset_factory(Author)
|
||||
|
||||
def test_simple_save(self):
|
||||
qs = Author.objects.all()
|
||||
AuthorFormSet = modelformset_factory(Author, fields="__all__", extra=3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue