1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #15896: Retain proper formatting for JSON custom field default values

This commit is contained in:
Jeremy Stretch
2024-04-30 16:13:17 -04:00
parent 11816b45e7
commit 365bb4ba17
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import decimal
import json
import re
from datetime import datetime, date
@ -484,7 +485,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
# JSON
elif self.type == CustomFieldTypeChoices.TYPE_JSON:
field = JSONField(required=required, initial=initial)
field = JSONField(required=required, initial=json.dumps(initial) if initial else '')
# Object
elif self.type == CustomFieldTypeChoices.TYPE_OBJECT: