mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 05:20:12 +03:00
Allow TimeField to specify defaults directly on class
This commit is contained in:
parent
ff28a6652d
commit
29f494f447
|
@ -948,12 +948,13 @@ class TimeField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('Time has wrong format. Use one of these formats instead: {format}'),
|
'invalid': _('Time has wrong format. Use one of these formats instead: {format}'),
|
||||||
}
|
}
|
||||||
|
# allows subclasses to change defaults
|
||||||
format = api_settings.TIME_FORMAT
|
format = api_settings.TIME_FORMAT
|
||||||
input_formats = api_settings.TIME_INPUT_FORMATS
|
input_formats = api_settings.TIME_INPUT_FORMATS
|
||||||
|
|
||||||
def __init__(self, format=empty, input_formats=None, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.format = format if format is not empty else self.format
|
self.format = kwargs.pop('format', self.format)
|
||||||
self.input_formats = input_formats if input_formats is not None else self.input_formats
|
self.input_formats = kwargs.pop('input_formats', self.input_formats)
|
||||||
super(TimeField, self).__init__(*args, **kwargs)
|
super(TimeField, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def to_internal_value(self, value):
|
def to_internal_value(self, value):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user