mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 05:20:12 +03:00
Allow FileField to specify defaults directly on class
This commit is contained in:
parent
29f494f447
commit
8471a4a2f7
|
@ -1084,11 +1084,14 @@ class FileField(Field):
|
|||
'empty': _("The submitted file is empty."),
|
||||
'max_length': _('Ensure this filename has at most {max_length} characters (it has {length}).'),
|
||||
}
|
||||
# allows subclasses to change defaults
|
||||
use_url = api_settings.UPLOADED_FILES_USE_URL
|
||||
max_length = None
|
||||
allow_empty_file = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.max_length = kwargs.pop('max_length', None)
|
||||
self.allow_empty_file = kwargs.pop('allow_empty_file', False)
|
||||
self.max_length = kwargs.pop('max_length', self.max_length)
|
||||
self.allow_empty_file = kwargs.pop('allow_empty_file', self.allow_empty_file)
|
||||
self.use_url = kwargs.pop('use_url', self.use_url)
|
||||
super(FileField, self).__init__(*args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user