mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #2402: Order and format JSON data in form fields
This commit is contained in:
parent
3a88e43103
commit
292647da14
@ -1,5 +1,9 @@
|
|||||||
v2.4.5 (FUTURE)
|
v2.4.5 (FUTURE)
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
* [#2402](https://github.com/digitalocean/netbox/issues/2402) - Order and format JSON data in form fields
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
* [#2406](https://github.com/digitalocean/netbox/issues/2406) - Remove hard-coded limit of 1000 objects from API-populated form fields
|
* [#2406](https://github.com/digitalocean/netbox/issues/2406) - Remove hard-coded limit of 1000 objects from API-populated form fields
|
||||||
|
@ -2,11 +2,12 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import csv
|
import csv
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.postgres.forms import JSONField as _JSONField
|
from django.contrib.postgres.forms.jsonb import JSONField as _JSONField, InvalidJSONInput
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from mptt.forms import TreeNodeMultipleChoiceField
|
from mptt.forms import TreeNodeMultipleChoiceField
|
||||||
@ -556,9 +557,11 @@ class JSONField(_JSONField):
|
|||||||
self.widget.attrs['placeholder'] = ''
|
self.widget.attrs['placeholder'] = ''
|
||||||
|
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
|
if isinstance(value, InvalidJSONInput):
|
||||||
|
return value
|
||||||
if value is None:
|
if value is None:
|
||||||
return ''
|
return ''
|
||||||
return super(JSONField, self).prepare_value(value)
|
return json.dumps(value, sort_keys=True, indent=4)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user