mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user