mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
fixes #2137 date type cutsom fields with webhooks
This coerses all date type custom field values to strings. This is due to a problem with serializing datetime objects.
This commit is contained in:
parent
beac676a6e
commit
65c2668478
@ -103,6 +103,9 @@ class CustomFieldModelSerializer(ValidatedModelSerializer):
|
||||
for cfv in instance.custom_field_values.all():
|
||||
if cfv.field.type == CF_TYPE_SELECT:
|
||||
custom_fields[cfv.field.name] = CustomFieldChoiceSerializer(cfv.value).data
|
||||
elif cfv.field.type == CF_TYPE_DATE:
|
||||
# convert datetime object to str
|
||||
custom_fields[cfv.field.name] = str(cfv.value)
|
||||
else:
|
||||
custom_fields[cfv.field.name] = cfv.value
|
||||
instance.custom_fields = custom_fields
|
||||
|
@ -177,7 +177,7 @@ class CustomFieldAPITest(HttpStatusMixin, APITestCase):
|
||||
(self.cf_text, 'Test string'),
|
||||
(self.cf_integer, 1234),
|
||||
(self.cf_boolean, True),
|
||||
(self.cf_date, date(2016, 6, 23)),
|
||||
(self.cf_date, "2016-06-23"),
|
||||
(self.cf_url, 'http://example.com/'),
|
||||
(self.cf_select, self.cf_select_choice1.pk),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user