@@ -115,13 +115,16 @@ class Meta:
115
115
"id" ,
116
116
"url" ,
117
117
"name" ,
118
+ "verbose_name" ,
119
+ "verbose_name_plural" ,
120
+ "slug" ,
118
121
"description" ,
119
122
"tags" ,
120
123
"created" ,
121
124
"last_updated" ,
122
125
"fields" ,
123
126
]
124
- brief_fields = ("id" , "url" , "name" , "description" )
127
+ brief_fields = ("id" , "url" , "name" , "slug" , " description" )
125
128
126
129
def create (self , validated_data ):
127
130
return super ().create (validated_data )
@@ -192,7 +195,7 @@ def get_url(self, obj):
192
195
lookup_value = getattr (obj , "pk" )
193
196
kwargs = {
194
197
"pk" : lookup_value ,
195
- "custom_object_type" : obj .custom_object_type .name . lower () ,
198
+ "custom_object_type" : obj .custom_object_type .slug ,
196
199
}
197
200
request = self .context ["request" ]
198
201
format = self .context .get ("format" )
@@ -203,7 +206,7 @@ def get_field_data(self, obj):
203
206
return result
204
207
205
208
206
- def get_serializer_class (model ):
209
+ def get_serializer_class (model , skip_object_fields = False ):
207
210
model_fields = model .custom_object_type .fields .all ()
208
211
209
212
# Create field list including all necessary fields
@@ -230,7 +233,7 @@ def get_url(self, obj):
230
233
lookup_value = getattr (obj , "pk" )
231
234
kwargs = {
232
235
"pk" : lookup_value ,
233
- "custom_object_type" : obj .custom_object_type .name . lower () ,
236
+ "custom_object_type" : obj .custom_object_type .slug ,
234
237
}
235
238
request = self .context ["request" ]
236
239
format = self .context .get ("format" )
@@ -251,6 +254,10 @@ def get_display(self, obj):
251
254
}
252
255
253
256
for field in model_fields :
257
+ if skip_object_fields and field .type in [
258
+ CustomFieldTypeChoices .TYPE_OBJECT , CustomFieldTypeChoices .TYPE_MULTIOBJECT
259
+ ]:
260
+ continue
254
261
field_type = field_types .FIELD_TYPE_CLASS [field .type ]()
255
262
try :
256
263
attrs [field .name ] = field_type .get_serializer_field (field )
0 commit comments