mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
move allow_blank to Field
This commit is contained in:
parent
8935db1be9
commit
73b2aff0e0
|
@ -170,7 +170,7 @@ class Field(object):
|
|||
def __init__(self, read_only=False, write_only=False,
|
||||
required=None, default=empty, initial=empty, source=None,
|
||||
label=None, help_text=None, style=None,
|
||||
error_messages=None, validators=None, allow_null=False):
|
||||
error_messages=None, validators=None, allow_null=False, allow_blank=False):
|
||||
self._creation_counter = Field._creation_counter
|
||||
Field._creation_counter += 1
|
||||
|
||||
|
@ -194,6 +194,7 @@ class Field(object):
|
|||
self.help_text = help_text
|
||||
self.style = {} if style is None else style
|
||||
self.allow_null = allow_null
|
||||
self.allow_blank = allow_blank
|
||||
|
||||
if self.default_empty_html is not empty:
|
||||
if not required:
|
||||
|
@ -564,7 +565,6 @@ class CharField(Field):
|
|||
initial = ''
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.allow_blank = kwargs.pop('allow_blank', False)
|
||||
self.trim_whitespace = kwargs.pop('trim_whitespace', True)
|
||||
self.max_length = kwargs.pop('max_length', None)
|
||||
self.min_length = kwargs.pop('min_length', None)
|
||||
|
@ -1110,8 +1110,6 @@ class ChoiceField(Field):
|
|||
(six.text_type(key), key) for key in self.choices.keys()
|
||||
])
|
||||
|
||||
self.allow_blank = kwargs.pop('allow_blank', False)
|
||||
|
||||
super(ChoiceField, self).__init__(**kwargs)
|
||||
|
||||
def to_internal_value(self, data):
|
||||
|
|
Loading…
Reference in New Issue
Block a user