diff options
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/fields.py | 24 | ||||
| -rw-r--r-- | django/forms/models.py | 10 |
2 files changed, 17 insertions, 17 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 979a13835d..13899c3ab1 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -541,9 +541,9 @@ class FileField(Field): 'contradiction': _('Please either submit a file or check the clear checkbox, not both.') } - def __init__(self, *args, **kwargs): - self.max_length = kwargs.pop('max_length', None) - self.allow_empty_file = kwargs.pop('allow_empty_file', False) + def __init__(self, *args, max_length=None, allow_empty_file=False, **kwargs): + self.max_length = max_length + self.allow_empty_file = allow_empty_file super().__init__(*args, **kwargs) def to_python(self, data): @@ -821,9 +821,9 @@ class ChoiceField(Field): class TypedChoiceField(ChoiceField): - def __init__(self, *args, **kwargs): - self.coerce = kwargs.pop('coerce', lambda val: val) - self.empty_value = kwargs.pop('empty_value', '') + def __init__(self, *args, coerce=lambda val: val, empty_value='', **kwargs): + self.coerce = coerce + self.empty_value = empty_value super().__init__(*args, **kwargs) def _coerce(self, value): @@ -890,8 +890,8 @@ class MultipleChoiceField(ChoiceField): class TypedMultipleChoiceField(MultipleChoiceField): - def __init__(self, *args, **kwargs): - self.coerce = kwargs.pop('coerce', lambda val: val) + def __init__(self, *args, coerce=lambda val: val, **kwargs): + self.coerce = coerce self.empty_value = kwargs.pop('empty_value', []) super().__init__(*args, **kwargs) @@ -971,8 +971,8 @@ class MultiValueField(Field): 'incomplete': _('Enter a complete value.'), } - def __init__(self, fields=(), *args, **kwargs): - self.require_all_fields = kwargs.pop('require_all_fields', True) + def __init__(self, fields=(), *args, require_all_fields=True, **kwargs): + self.require_all_fields = require_all_fields super().__init__(*args, **kwargs) for f in fields: f.error_messages.setdefault('incomplete', @@ -1174,8 +1174,8 @@ class GenericIPAddressField(CharField): class SlugField(CharField): default_validators = [validators.validate_slug] - def __init__(self, *args, **kwargs): - self.allow_unicode = kwargs.pop('allow_unicode', False) + def __init__(self, *args, allow_unicode=False, **kwargs): + self.allow_unicode = allow_unicode if self.allow_unicode: self.default_validators = [validators.validate_unicode_slug] super().__init__(*args, **kwargs) diff --git a/django/forms/models.py b/django/forms/models.py index a95f281b45..0368839415 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -553,9 +553,9 @@ class BaseModelFormSet(BaseFormSet): unique_fields = set() def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, - queryset=None, **kwargs): + queryset=None, *, initial=None, **kwargs): self.queryset = queryset - self.initial_extra = kwargs.pop('initial', None) + self.initial_extra = initial defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix} defaults.update(kwargs) super().__init__(**defaults) @@ -1065,10 +1065,10 @@ class InlineForeignKeyField(Field): 'invalid_choice': _('The inline foreign key did not match the parent instance primary key.'), } - def __init__(self, parent_instance, *args, **kwargs): + def __init__(self, parent_instance, *args, pk_field=False, to_field=None, **kwargs): self.parent_instance = parent_instance - self.pk_field = kwargs.pop("pk_field", False) - self.to_field = kwargs.pop("to_field", None) + self.pk_field = pk_field + self.to_field = to_field if self.parent_instance is not None: if self.to_field: kwargs["initial"] = getattr(self.parent_instance, self.to_field) |
