mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-30 02:13:29 +03:00
Made field label optional in OPTIONS
This commit is contained in:
parent
42b61ffcd7
commit
b915c1d4d8
|
@ -136,11 +136,10 @@ def humanize_field(field):
|
||||||
humanized = {
|
humanized = {
|
||||||
'type': humanize_field_type(field.__class__),
|
'type': humanize_field_type(field.__class__),
|
||||||
'required': getattr(field, 'required', False),
|
'required': getattr(field, 'required', False),
|
||||||
'label': getattr(field, 'label', None),
|
|
||||||
}
|
}
|
||||||
optional_attrs = ['read_only', 'help_text']
|
optional_attrs = ['read_only', 'help_text', 'label']
|
||||||
for attr in optional_attrs:
|
for attr in optional_attrs:
|
||||||
if hasattr(field, attr):
|
if getattr(field, attr, None) is not None:
|
||||||
humanized[attr] = getattr(field, attr)
|
humanized[attr] = getattr(field, attr)
|
||||||
return humanized
|
return humanized
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user