mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 13:04:03 +03:00
Browsable API tweaks
This commit is contained in:
parent
df7b6fcf58
commit
fec7c4b458
|
@ -106,7 +106,7 @@ class Field(object):
|
||||||
'null': _('This field may not be null.')
|
'null': _('This field may not be null.')
|
||||||
}
|
}
|
||||||
default_validators = []
|
default_validators = []
|
||||||
default_empty_html = None
|
default_empty_html = empty
|
||||||
initial = None
|
initial = None
|
||||||
|
|
||||||
def __init__(self, read_only=False, write_only=False,
|
def __init__(self, read_only=False, write_only=False,
|
||||||
|
@ -375,7 +375,6 @@ class NullBooleanField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('`{input}` is not a valid boolean.')
|
'invalid': _('`{input}` is not a valid boolean.')
|
||||||
}
|
}
|
||||||
default_empty_html = None
|
|
||||||
initial = None
|
initial = None
|
||||||
TRUE_VALUES = set(('t', 'T', 'true', 'True', 'TRUE', '1', 1, True))
|
TRUE_VALUES = set(('t', 'T', 'true', 'True', 'TRUE', '1', 1, True))
|
||||||
FALSE_VALUES = set(('f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False))
|
FALSE_VALUES = set(('f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False))
|
||||||
|
@ -411,7 +410,6 @@ class CharField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'blank': _('This field may not be blank.')
|
'blank': _('This field may not be blank.')
|
||||||
}
|
}
|
||||||
default_empty_html = ''
|
|
||||||
initial = ''
|
initial = ''
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -852,6 +850,7 @@ class MultipleChoiceField(ChoiceField):
|
||||||
'invalid_choice': _('`{input}` is not a valid choice.'),
|
'invalid_choice': _('`{input}` is not a valid choice.'),
|
||||||
'not_a_list': _('Expected a list of items but got type `{input_type}`')
|
'not_a_list': _('Expected a list of items but got type `{input_type}`')
|
||||||
}
|
}
|
||||||
|
default_empty_html = []
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
if isinstance(data, type('')) or not hasattr(data, '__iter__'):
|
if isinstance(data, type('')) or not hasattr(data, '__iter__'):
|
||||||
|
|
|
@ -249,6 +249,7 @@ class ManyRelation(Field):
|
||||||
You shouldn't need to be using this class directly yourself.
|
You shouldn't need to be using this class directly yourself.
|
||||||
"""
|
"""
|
||||||
initial = []
|
initial = []
|
||||||
|
default_empty_html = []
|
||||||
|
|
||||||
def __init__(self, child_relation=None, *args, **kwargs):
|
def __init__(self, child_relation=None, *args, **kwargs):
|
||||||
self.child_relation = child_relation
|
self.child_relation = child_relation
|
||||||
|
|
|
@ -254,6 +254,7 @@ class Serializer(BaseSerializer):
|
||||||
return ReturnDict([
|
return ReturnDict([
|
||||||
(field_name, field.get_value(self._initial_data))
|
(field_name, field.get_value(self._initial_data))
|
||||||
for field_name, field in self.fields.items()
|
for field_name, field in self.fields.items()
|
||||||
|
if field.get_value(self._initial_data) is not empty
|
||||||
], serializer=self)
|
], serializer=self)
|
||||||
#return self.to_representation(self._initial_data)
|
#return self.to_representation(self._initial_data)
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ footer a:hover {
|
||||||
.page-header {
|
.page-header {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
padding-bottom: 0px;
|
padding-bottom: 0px;
|
||||||
margin-bottom: 20px;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* custom general page styles */
|
/* custom general page styles */
|
||||||
|
|
|
@ -33,7 +33,7 @@ h2, h3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.breadcrumb {
|
ul.breadcrumb {
|
||||||
margin: 80px 0 0 0;
|
margin: 70px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
form select, form input, form textarea {
|
form select, form input, form textarea {
|
||||||
|
@ -67,5 +67,4 @@ pre {
|
||||||
.page-header {
|
.page-header {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
padding-bottom: 0px;
|
padding-bottom: 0px;
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user