File tree Expand file tree Collapse file tree 3 files changed +20
-21
lines changed Expand file tree Collapse file tree 3 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ def humanize_field(field):
136
136
humanized = {
137
137
'type' : humanize_field_type (field .__class__ ),
138
138
'required' : getattr (field , 'required' , False ),
139
- 'label' : field . label ,
139
+ 'label' : getattr ( field , ' label' , None ) ,
140
140
}
141
141
optional_attrs = ['read_only' , 'help_text' ]
142
142
for attr in optional_attrs :
Original file line number Diff line number Diff line change @@ -128,18 +128,18 @@ def test_options_root_view(self):
128
128
for method in ('GET' , 'POST' ,):
129
129
expected ['actions' ][method ] = {
130
130
'text' : {
131
- 'description' : '' ,
132
- 'label' : '' ,
133
- 'readonly ' : False ,
131
+ # 'description': '',
132
+ 'label' : None ,
133
+ 'read_only ' : False ,
134
134
'required' : True ,
135
- 'type' : 'CharField ' ,
135
+ 'type' : 'Single Character ' ,
136
136
},
137
137
'id' : {
138
- 'description' : '' ,
139
- 'label' : '' ,
140
- 'readonly ' : True ,
141
- 'required' : True ,
142
- 'type' : 'IntegerField ' ,
138
+ # 'description': '',
139
+ 'label' : None ,
140
+ 'read_only ' : True ,
141
+ 'required' : False ,
142
+ 'type' : 'Integer ' ,
143
143
},
144
144
}
145
145
self .assertEqual (response .status_code , status .HTTP_200_OK )
@@ -264,18 +264,18 @@ def test_options_instance_view(self):
264
264
for method in ('GET' , 'PATCH' , 'PUT' , 'DELETE' ):
265
265
expected ['actions' ][method ] = {
266
266
'text' : {
267
- 'description' : '' ,
268
- 'label' : '' ,
269
- 'readonly ' : False ,
267
+ # 'description': '',
268
+ 'label' : None ,
269
+ 'read_only ' : False ,
270
270
'required' : True ,
271
- 'type' : 'CharField ' ,
271
+ 'type' : 'Single Character ' ,
272
272
},
273
273
'id' : {
274
- 'description' : '' ,
275
- 'label' : '' ,
276
- 'readonly ' : True ,
277
- 'required' : True ,
278
- 'type' : 'IntegerField ' ,
274
+ # 'description': '',
275
+ 'label' : None ,
276
+ 'read_only ' : True ,
277
+ 'required' : False ,
278
+ 'type' : 'Integer ' ,
279
279
},
280
280
}
281
281
self .assertEqual (response .status_code , status .HTTP_200_OK )
Original file line number Diff line number Diff line change @@ -85,8 +85,7 @@ def _generate_action_metadata(self, request):
85
85
field_name_types = {}
86
86
for name , field in serializer .fields .iteritems ():
87
87
from rest_framework .fields import humanize_field
88
- humanize_field (field )
89
- field_name_types [name ] = field .__class__ .__name__
88
+ field_name_types [name ] = humanize_field (field )
90
89
91
90
actions [method ] = field_name_types
92
91
except exceptions .PermissionDenied :
You can’t perform that action at this time.
0 commit comments