Ticket #10403: django-10403.diff

File django-10403.diff, 27.7 KB (added by Bas Peschier, 13 years ago)
  • django/contrib/admin/options.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/contrib/admin/options.py
    a b  
    22from django import forms
    33from django.forms.formsets import all_valid
    44from django.forms.models import (modelform_factory, modelformset_factory,
    5     inlineformset_factory, BaseInlineFormSet)
     5    inlineformset_factory, InlineFormSet)
    66from django.contrib.contenttypes.models import ContentType
    77from django.contrib.admin import widgets, helpers
    88from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects, model_format_dict
     
    13021302    """
    13031303    model = None
    13041304    fk_name = None
    1305     formset = BaseInlineFormSet
     1305    formset = InlineFormSet
    13061306    extra = 3
    13071307    max_num = None
    13081308    template = None
     
    13321332    media = property(_media)
    13331333
    13341334    def get_formset(self, request, obj=None, **kwargs):
    1335         """Returns a BaseInlineFormSet class for use in admin add/change views."""
     1335        """Returns a InlineFormSet class for use in admin add/change views."""
    13361336        if self.declared_fieldsets:
    13371337            fields = flatten_fieldsets(self.declared_fieldsets)
    13381338        else:
  • django/contrib/admin/validation.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/contrib/admin/validation.py
    a b  
    11from django.core.exceptions import ImproperlyConfigured
    22from django.db import models
    33from django.db.models.fields import FieldDoesNotExist
    4 from django.forms.models import (BaseModelForm, BaseModelFormSet, fields_for_model,
     4from django.forms.models import (BaseModelForm, ModelFormSet, fields_for_model,
    55    _get_foreign_key)
    66from django.contrib.admin import ListFilter, FieldListFilter
    77from django.contrib.admin.util import get_fields_from_path, NotRelationField
     
    206206                % cls.__name__)
    207207
    208208    # formset
    209     if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):
     209    if hasattr(cls, 'formset') and not issubclass(cls.formset, ModelFormSet):
    210210        raise ImproperlyConfigured("'%s.formset' does not inherit from "
    211                 "BaseModelFormSet." % cls.__name__)
     211                "ModelFormSet." % cls.__name__)
    212212
    213213    # exclude
    214214    if hasattr(cls, 'exclude') and cls.exclude:
  • django/contrib/contenttypes/generic.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/contrib/contenttypes/generic.py
    a b  
    1010from django.db.models.fields.related import RelatedField, Field, ManyToManyRel
    1111from django.db.models.loading import get_model
    1212from django.forms import ModelForm
    13 from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance
     13from django.forms.models import ModelFormSet, modelformset_factory, save_instance
    1414from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
    1515from django.contrib.contenttypes.models import ContentType
    1616from django.utils.encoding import smart_unicode
     
    310310        self.multiple = True
    311311        self.through = None
    312312
    313 class BaseGenericInlineFormSet(BaseModelFormSet):
     313class BaseGenericInlineFormSet(ModelFormSet):
    314314    """
    315315    A formset for generic inline objects to a parent.
    316316    """
     
    341341
    342342    @classmethod
    343343    def get_default_prefix(cls):
    344         opts = cls.model._meta
     344        opts = cls.form._meta.model._meta
    345345        return '-'.join((opts.app_label, opts.object_name.lower(),
    346346                        cls.ct_field.name, cls.ct_fk_field.name,
    347347        ))
  • django/contrib/formtools/wizard/views.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/contrib/formtools/wizard/views.py
    a b  
    155155
    156156        # walk through the ne created list of forms
    157157        for form in init_form_list.itervalues():
    158             if issubclass(form, formsets.BaseFormSet):
    159                 # if the element is based on BaseFormSet (FormSet/ModelFormSet)
     158            if issubclass(form, formsets.FormSet):
     159                # if the element is based on FormSet (FormSet/ModelFormSet)
    160160                # we need to override the form variable.
    161161                form = form.form
    162162            # check if any form contains a FileField, if yes, we need a
     
    383383        if issubclass(self.form_list[step], forms.ModelForm):
    384384            # If the form is based on ModelForm, add instance if available.
    385385            kwargs.update({'instance': self.get_form_instance(step)})
    386         elif issubclass(self.form_list[step], forms.models.BaseModelFormSet):
     386        elif issubclass(self.form_list[step], forms.models.ModelFormSet):
    387387            # If the form is based on ModelFormSet, add queryset if available.
    388388            kwargs.update({'queryset': self.get_form_instance(step)})
    389389        return self.form_list[step](**kwargs)
  • django/forms/formsets.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/forms/formsets.py
    a b  
     1import warnings
     2
    13from forms import Form
    2 from django.core.exceptions import ValidationError
     4from django.core.exceptions import ValidationError, ImproperlyConfigured
    35from django.utils.encoding import StrAndUnicode
    46from django.utils.safestring import mark_safe
    57from django.utils.translation import ugettext as _
     
    79from widgets import Media, HiddenInput
    810from util import ErrorList
    911
    10 __all__ = ('BaseFormSet', 'all_valid')
     12__all__ = ('BaseFormSet', 'FormSet', 'all_valid')
    1113
    1214# special field names
    1315TOTAL_FORM_COUNT = 'TOTAL_FORMS'
     
    2830        self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
    2931        super(ManagementForm, self).__init__(*args, **kwargs)
    3032
    31 class BaseFormSet(StrAndUnicode):
     33
     34class FormSet(StrAndUnicode):
    3235    """
    3336    A collection of instances of the same Form class.
    3437    """
     38
     39    form = None
     40    extra = 1
     41    can_order = False
     42    can_delete = False
     43    max_num = None
     44
    3545    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
    3646                 initial=None, error_class=ErrorList):
    3747        self.is_bound = data is not None or files is not None
     
    4353        self.error_class = error_class
    4454        self._errors = None
    4555        self._non_form_errors = None
     56        # check declaration of FormSet
     57        if self.form is None:
     58            raise ImproperlyConfigured("FormSet declaration does not contain "
     59                "'form' value.")
    4660        # construct the forms in the formset
    4761        self._construct_forms()
    4862
     
    344358        forms = u' '.join([form.as_ul() for form in self])
    345359        return mark_safe(u'\n'.join([unicode(self.management_form), forms]))
    346360
    347 def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
    348                     can_delete=False, max_num=None):
     361class BaseFormSet(FormSet):
     362    warnings.warn("BaseFormSet has been renamed to FormSet.",
     363        PendingDeprecationWarning)
     364
     365def formset_factory(form, formset=FormSet, **kwargs):
    349366    """Return a FormSet for the given form class."""
    350     attrs = {'form': form, 'extra': extra,
    351              'can_order': can_order, 'can_delete': can_delete,
    352              'max_num': max_num}
    353     return type(form.__name__ + 'FormSet', (formset,), attrs)
     367
     368    warnings.warn("formset_factory is deprecated. Use a declarative FormSet "
     369                      "instead.", PendingDeprecationWarning)
     370
     371    kwargs.update({'form': form,})
     372    return type(form.__name__ + 'FormSet', (formset,), kwargs)
    354373
    355374def all_valid(formsets):
    356375    """Returns true if every formset in formsets is valid."""
  • django/forms/models.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 django/forms/models.py
    a b  
    33and database field objects.
    44"""
    55
     6import warnings
     7
    68from django.utils.encoding import smart_unicode, force_unicode
    79from django.utils.datastructures import SortedDict
    810from django.utils.text import get_text_list, capfirst
     
    1618from fields import Field, ChoiceField
    1719from widgets import SelectMultiple, HiddenInput, MultipleHiddenInput
    1820from widgets import media_property
    19 from formsets import BaseFormSet, formset_factory
     21from formsets import FormSet, formset_factory
    2022
    2123__all__ = (
    2224    'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model',
     
    406408
    407409# ModelFormSets ##############################################################
    408410
    409 class BaseModelFormSet(BaseFormSet):
     411class ModelFormSet(FormSet):
    410412    """
    411413    A ``FormSet`` for editing a queryset and/or adding new objects to it.
    412414    """
    413     model = None
    414415
    415416    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
    416417                 queryset=None, **kwargs):
    417418        self.queryset = queryset
    418419        defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix}
    419420        defaults.update(kwargs)
    420         super(BaseModelFormSet, self).__init__(**defaults)
     421        super(ModelFormSet, self).__init__(**defaults)
     422
     423    @property
     424    def model(cls):
     425        return cls.form._meta.model
    421426
    422427    def initial_form_count(self):
    423428        """Returns the number of forms that are required in this FormSet."""
    424429        if not (self.data or self.files):
    425430            return len(self.get_queryset())
    426         return super(BaseModelFormSet, self).initial_form_count()
     431        return super(ModelFormSet, self).initial_form_count()
    427432
    428433    def _existing_object(self, pk):
    429434        if not hasattr(self, '_object_dict'):
     
    435440            # Import goes here instead of module-level because importing
    436441            # django.db has side effects.
    437442            from django.db import connections
    438             pk_key = "%s-%s" % (self.add_prefix(i), self.model._meta.pk.name)
     443            pk_key = "%s-%s" % (self.add_prefix(i),
     444                self.model._meta.pk.name)
    439445            pk = self.data[pk_key]
    440446            pk_field = self.model._meta.pk
    441447            pk = pk_field.get_db_prep_lookup('exact', pk,
     
    445451            kwargs['instance'] = self._existing_object(pk)
    446452        if i < self.initial_form_count() and not kwargs.get('instance'):
    447453            kwargs['instance'] = self.get_queryset()[i]
    448         return super(BaseModelFormSet, self)._construct_form(i, **kwargs)
     454        return super(ModelFormSet, self)._construct_form(i, **kwargs)
    449455
    450456    def get_queryset(self):
    451457        if not hasattr(self, '_queryset'):
     
    649655                qs = self.model._default_manager.get_query_set()
    650656            qs = qs.using(form.instance._state.db)
    651657            form.fields[self._pk_field.name] = ModelChoiceField(qs, initial=pk_value, required=False, widget=HiddenInput)
    652         super(BaseModelFormSet, self).add_fields(form, index)
     658        super(ModelFormSet, self).add_fields(form, index)
    653659
    654 def modelformset_factory(model, form=ModelForm, formfield_callback=None,
    655                          formset=BaseModelFormSet,
    656                          extra=1, can_delete=False, can_order=False,
    657                          max_num=None, fields=None, exclude=None):
     660class BaseModelFormSet(ModelFormSet):
     661    warnings.warn("BaseModelFormSet has been renamed to ModelFormSet.",
     662        PendingDeprecationWarning)
     663
     664def modelformset_factory(model, form=ModelForm, formset=ModelFormSet,
     665                formfield_callback=None, fields=None, exclude=None, **kwargs):
    658666    """
    659667    Returns a FormSet class for the given Django model class.
    660668    """
     669
     670    warnings.warn("modelformset_factory is deprecated. Use a declarative "
     671                    "ModelFormSet instead.", PendingDeprecationWarning)
     672
     673
    661674    form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
    662675                             formfield_callback=formfield_callback)
    663     FormSet = formset_factory(form, formset, extra=extra, max_num=max_num,
    664                               can_order=can_order, can_delete=can_delete)
    665     FormSet.model = model
    666     return FormSet
    667 
     676    return formset_factory(form, formset, **kwargs)
    668677
    669678# InlineFormSets #############################################################
    670679
    671 class BaseInlineFormSet(BaseModelFormSet):
    672     """A formset for child objects related to a parent."""
    673     def __init__(self, data=None, files=None, instance=None,
    674                  save_as_new=False, prefix=None, queryset=None):
    675         from django.db.models.fields.related import RelatedObject
    676         if instance is None:
    677             self.instance = self.fk.rel.to()
    678         else:
    679             self.instance = instance
    680         self.save_as_new = save_as_new
    681         # is there a better way to get the object descriptor?
    682         self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name()
    683         if queryset is None:
    684             queryset = self.model._default_manager
    685         qs = queryset.filter(**{self.fk.name: self.instance})
    686         super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix,
    687                                                 queryset=qs)
    688 
    689     def initial_form_count(self):
    690         if self.save_as_new:
    691             return 0
    692         return super(BaseInlineFormSet, self).initial_form_count()
    693 
    694 
    695     def _construct_form(self, i, **kwargs):
    696         form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
    697         if self.save_as_new:
    698             # Remove the primary key from the form's data, we are only
    699             # creating new instances
    700             form.data[form.add_prefix(self._pk_field.name)] = None
    701 
    702             # Remove the foreign key from the form's data
    703             form.data[form.add_prefix(self.fk.name)] = None
    704 
    705         # Set the fk value here so that the form can do it's validation.
    706         setattr(form.instance, self.fk.get_attname(), self.instance.pk)
    707         return form
    708 
    709     @classmethod
    710     def get_default_prefix(cls):
    711         from django.db.models.fields.related import RelatedObject
    712         return RelatedObject(cls.fk.rel.to, cls.model, cls.fk).get_accessor_name().replace('+','')
    713 
    714     def save_new(self, form, commit=True):
    715         # Use commit=False so we can assign the parent key afterwards, then
    716         # save the object.
    717         obj = form.save(commit=False)
    718         pk_value = getattr(self.instance, self.fk.rel.field_name)
    719         setattr(obj, self.fk.get_attname(), getattr(pk_value, 'pk', pk_value))
    720         if commit:
    721             obj.save()
    722         # form.save_m2m() can be called via the formset later on if commit=False
    723         if commit and hasattr(form, 'save_m2m'):
    724             form.save_m2m()
    725         return obj
    726 
    727     def add_fields(self, form, index):
    728         super(BaseInlineFormSet, self).add_fields(form, index)
    729         if self._pk_field == self.fk:
    730             name = self._pk_field.name
    731             kwargs = {'pk_field': True}
    732         else:
    733             # The foreign key field might not be on the form, so we poke at the
    734             # Model field to get the label, since we need that for error messages.
    735             name = self.fk.name
    736             kwargs = {
    737                 'label': getattr(form.fields.get(name), 'label', capfirst(self.fk.verbose_name))
    738             }
    739             if self.fk.rel.field_name != self.fk.rel.to._meta.pk.name:
    740                 kwargs['to_field'] = self.fk.rel.field_name
    741 
    742         form.fields[name] = InlineForeignKeyField(self.instance, **kwargs)
    743 
    744         # Add the generated field to form._meta.fields if it's defined to make
    745         # sure validation isn't skipped on that field.
    746         if form._meta.fields:
    747             if isinstance(form._meta.fields, tuple):
    748                 form._meta.fields = list(form._meta.fields)
    749             form._meta.fields.append(self.fk.name)
    750 
    751     def get_unique_error_message(self, unique_check):
    752         unique_check = [field for field in unique_check if field != self.fk.name]
    753         return super(BaseInlineFormSet, self).get_unique_error_message(unique_check)
    754 
    755 
    756680def _get_foreign_key(parent_model, model, fk_name=None, can_fail=False):
    757681    """
    758682    Finds and returns the ForeignKey from model to parent if there is one
     
    793717    return fk
    794718
    795719
    796 def inlineformset_factory(parent_model, model, form=ModelForm,
    797                           formset=BaseInlineFormSet, fk_name=None,
    798                           fields=None, exclude=None,
    799                           extra=3, can_order=False, can_delete=True, max_num=None,
    800                           formfield_callback=None):
     720
     721class InlineFormSetMetaclass(type):
     722
     723    def __new__(cls, name, bases, attrs):
     724        try:
     725            parents = [b for b in bases if issubclass(b, InlineFormSet)]
     726        except NameError:
     727            # we are defining InlineFormSet ourselves
     728            parents = None
     729
     730        new_class = super(InlineFormSetMetaclass, cls).__new__(cls, name,
     731                            bases, attrs)
     732        if not parents:
     733            return new_class
     734
     735        # Find parent model
     736        parent_model = attrs.get('parent_model', None)
     737        fk_name = attrs.get('fk_name', None)
     738        form = attrs.get('form', None)
     739        for base in parents:
     740            parent_model = parent_model or getattr(base, 'parent_model', None)
     741            fk_name = fk_name or getattr(base, 'fk_name', None)
     742            form = form or getattr(base, 'form', None)
     743
     744        # enforce a max_num=1 when the foreign key
     745        # to the parent model is unique.
     746        if form and parent_model:
     747            new_class.fk = _get_foreign_key(parent_model,
     748                form._meta.model, fk_name=fk_name)
     749            if new_class.fk.unique:
     750                new_class.max_num = 1
     751
     752        new_class.parent_model = parent_model
     753        new_class.fk_name = fk_name
     754        new_class.form = form
     755
     756        return new_class
     757
     758
     759class InlineFormSet(ModelFormSet):
     760    """A formset for child objects related to a parent."""
     761    __metaclass__ = InlineFormSetMetaclass
     762
     763    parent_model = None
     764    fk_name = None
     765
     766    def __init__(self, data=None, files=None, instance=None,
     767                 save_as_new=False, prefix=None, queryset=None):
     768
     769        from django.db.models.fields.related import RelatedObject
     770        if instance is None:
     771            self.instance = self.fk.rel.to()
     772        else:
     773            self.instance = instance
     774        self.save_as_new = save_as_new
     775        # is there a better way to get the object descriptor?
     776        self.rel_name = RelatedObject(self.fk.rel.to, self.form._meta.model,
     777                                        self.fk).get_accessor_name()
     778        if queryset is None:
     779            queryset = self.form._meta.model._default_manager
     780        qs = queryset.filter(**{self.fk.name: self.instance})
     781        super(InlineFormSet, self).__init__(data, files, prefix=prefix,
     782                                                queryset=qs)
     783
     784    def initial_form_count(self):
     785        if self.save_as_new:
     786            return 0
     787        return super(InlineFormSet, self).initial_form_count()
     788
     789
     790    def _construct_form(self, i, **kwargs):
     791        form = super(InlineFormSet, self)._construct_form(i, **kwargs)
     792        if self.save_as_new:
     793            # Remove the primary key from the form's data, we are only
     794            # creating new instances
     795            form.data[form.add_prefix(self._pk_field.name)] = None
     796
     797            # Remove the foreign key from the form's data
     798            form.data[form.add_prefix(self.fk.name)] = None
     799
     800        # Set the fk value here so that the form can do it's validation.
     801        setattr(form.instance, self.fk.get_attname(), self.instance.pk)
     802        return form
     803
     804    @classmethod
     805    def get_default_prefix(cls):
     806        from django.db.models.fields.related import RelatedObject
     807        fk = _get_foreign_key(cls.parent_model, cls.form._meta.model,
     808                                fk_name=cls.fk_name)
     809        return RelatedObject(fk.rel.to, cls.form._meta.model,
     810                                fk).get_accessor_name().replace('+','')
     811
     812    def save_new(self, form, commit=True):
     813        # Use commit=False so we can assign the parent key afterwards, then
     814        # save the object.
     815        obj = form.save(commit=False)
     816        pk_value = getattr(self.instance, self.fk.rel.field_name)
     817        setattr(obj, self.fk.get_attname(), getattr(pk_value, 'pk', pk_value))
     818        if commit:
     819            obj.save()
     820        # form.save_m2m() can be called via the formset later on if commit=False
     821        if commit and hasattr(form, 'save_m2m'):
     822            form.save_m2m()
     823        return obj
     824
     825    def add_fields(self, form, index):
     826        super(InlineFormSet, self).add_fields(form, index)
     827        if self._pk_field == self.fk:
     828            name = self._pk_field.name
     829            kwargs = {'pk_field': True}
     830        else:
     831            # The foreign key field might not be on the form, so we poke at the
     832            # Model field to get the label, since we need that for error messages.
     833            name = self.fk.name
     834            kwargs = {
     835                'label': getattr(form.fields.get(name), 'label', capfirst(self.fk.verbose_name))
     836            }
     837            if self.fk.rel.field_name != self.fk.rel.to._meta.pk.name:
     838                kwargs['to_field'] = self.fk.rel.field_name
     839
     840        form.fields[name] = InlineForeignKeyField(self.instance, **kwargs)
     841
     842        # Add the generated field to form._meta.fields if it's defined to make
     843        # sure validation isn't skipped on that field.
     844        if form._meta.fields:
     845            if isinstance(form._meta.fields, tuple):
     846                form._meta.fields = list(form._meta.fields)
     847            form._meta.fields.append(self.fk.name)
     848
     849    def get_unique_error_message(self, unique_check):
     850        unique_check = [field for field in unique_check if field != self.fk.name]
     851        return super(InlineFormSet, self).get_unique_error_message(unique_check)
     852
     853class BaseInlineFormSet(InlineFormSet):
     854    warnings.warn("BaseInlineFormSet has been renamed to InlineFormSet.",
     855        PendingDeprecationWarning)
     856
     857def inlineformset_factory(parent_model, model, formset=InlineFormSet,
     858                            fk_name=None, **kwargs):
    801859    """
    802860    Returns an ``InlineFormSet`` for the given kwargs.
    803861
    804862    You must provide ``fk_name`` if ``model`` has more than one ``ForeignKey``
    805863    to ``parent_model``.
    806864    """
    807     fk = _get_foreign_key(parent_model, model, fk_name=fk_name)
    808     # enforce a max_num=1 when the foreign key to the parent model is unique.
    809     if fk.unique:
    810         max_num = 1
    811     kwargs = {
    812         'form': form,
    813         'formfield_callback': formfield_callback,
     865
     866    warnings.warn("inlineformset_factory is deprecated. Use a declarative "
     867                    "InlineFormSet instead.", PendingDeprecationWarning)
     868
     869    kwargs.update({
    814870        'formset': formset,
    815         'extra': extra,
    816         'can_delete': can_delete,
    817         'can_order': can_order,
    818         'fields': fields,
    819         'exclude': exclude,
    820         'max_num': max_num,
    821     }
    822     FormSet = modelformset_factory(model, **kwargs)
    823     FormSet.fk = fk
    824     return FormSet
     871        'parent_model': parent_model,
     872        'fk_name': fk_name,
     873    })
     874    return modelformset_factory(model, **kwargs)
    825875
    826876
    827877# Fields #####################################################################
  • tests/regressiontests/admin_views/models.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 tests/regressiontests/admin_views/models.py
    a b  
    99from django.core.mail import EmailMessage
    1010from django.db import models
    1111from django import forms
    12 from django.forms.models import BaseModelFormSet
     12from django.forms.models import ModelFormSet
    1313from django.contrib.auth.models import User
    1414from django.contrib.contenttypes import generic
    1515from django.contrib.contenttypes.models import ContentType
     
    243243    def __unicode__(self):
    244244        return self.name
    245245
    246 class BasePersonModelFormSet(BaseModelFormSet):
     246class BasePersonModelFormSet(ModelFormSet):
    247247    def clean(self):
    248248        for person_dict in self.cleaned_data:
    249249            person = person_dict.get('id')
  • tests/regressiontests/forms/tests/formsets.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 tests/regressiontests/forms/tests/formsets.py
    a b  
    11# -*- coding: utf-8 -*-
    22from django.forms import Form, CharField, IntegerField, ValidationError, DateField
    3 from django.forms.formsets import formset_factory, BaseFormSet
     3from django.forms.formsets import formset_factory, FormSet
    44from django.utils.unittest import TestCase
    55
    66
     
    1818    name = CharField()
    1919
    2020
    21 class BaseFavoriteDrinksFormSet(BaseFormSet):
     21class BaseFavoriteDrinksFormSet(FormSet):
    2222    def clean(self):
    2323        seen_drinks = []
    2424
     
    2929            seen_drinks.append(drink['name'])
    3030
    3131
    32 class EmptyFsetWontValidate(BaseFormSet):
     32class EmptyFsetWontValidate(FormSet):
    3333    def clean(self):
    3434        raise ValidationError("Clean method called")
    3535
     
    791791            pass
    792792
    793793        # Formets can override the default iteration order
    794         class BaseReverseFormSet(BaseFormSet):
     794        class BaseReverseFormSet(FormSet):
    795795            def __iter__(self):
    796796                for form in reversed(self.forms):
    797797                    yield form
  • tests/regressiontests/model_formsets_regress/tests.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 tests/regressiontests/model_formsets_regress/tests.py
    a b  
    11from django import forms
    22from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME
    33from django.forms.util import ErrorDict, ErrorList
    4 from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, BaseModelFormSet
     4from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, ModelFormSet
    55from django.test import TestCase
    66
    77from models import User, UserSite, Restaurant, Manager, Network, Host
     
    305305
    306306class FormfieldShouldDeleteFormTests(TestCase):
    307307    """
    308     Regression for #14099: BaseModelFormSet should use ModelFormSet method _should_delete_form
     308    Regression for #14099: ModelFormSet should use ModelFormSet method _should_delete_form
    309309    """
    310310
    311     class BaseCustomDeleteModelFormSet(BaseModelFormSet, BaseCustomDeleteFormSet):
     311    class BaseCustomDeleteModelFormSet(ModelFormSet, BaseCustomDeleteFormSet):
    312312        """ Model FormSet with CustomDelete MixIn """
    313313
    314314    class CustomDeleteUserForm(forms.ModelForm):
  • tests/regressiontests/modeladmin/tests.py

    diff -r 1640f4c5fbe1 -r 0b890d4cda73 tests/regressiontests/modeladmin/tests.py
    a b  
    1010from django.contrib.admin import (SimpleListFilter,
    1111     BooleanFieldListFilter)
    1212from django.core.exceptions import ImproperlyConfigured
    13 from django.forms.models import BaseModelFormSet
     13from django.forms.models import ModelFormSet
    1414from django.forms.widgets import Select
    1515from django.test import TestCase
    1616from django.utils import unittest
     
    13261326
    13271327        self.assertRaisesRegexp(
    13281328            ImproperlyConfigured,
    1329             "'ValidationTestInline.formset' does not inherit from BaseModelFormSet.",
     1329            "'ValidationTestInline.formset' does not inherit from ModelFormSet.",
    13301330            validate,
    13311331            ValidationTestModelAdmin,
    13321332            ValidationTestModel,
    13331333        )
    13341334
    1335         class RealModelFormSet(BaseModelFormSet):
     1335        class RealModelFormSet(ModelFormSet):
    13361336            pass
    13371337
    13381338        class ValidationTestInline(TabularInline):
Back to Top