Skip to content

Commit 26a7726

Browse files
pushpit kambojpushpit kamboj
authored andcommitted
[change] Replaced third-party jsonfield with Django's built-in JSONField
1 parent 1363d26 commit 26a7726

6 files changed

Lines changed: 112 additions & 13 deletions

File tree

openwisp_monitoring/check/base/models.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from collections import OrderedDict
2-
31
from django.contrib.contenttypes.fields import GenericForeignKey
42
from django.contrib.contenttypes.models import ContentType
53
from django.db import models
64
from django.utils.functional import cached_property
75
from django.utils.module_loading import import_string
86
from django.utils.translation import gettext_lazy as _
9-
from jsonfield import JSONField
107

118
from openwisp_utils.base import TimeStampedEditableModel
129

@@ -37,13 +34,11 @@ class AbstractCheck(TimeStampedEditableModel):
3734
db_index=True,
3835
max_length=128,
3936
)
40-
params = JSONField(
37+
params = models.JSONField(
4138
_("parameters"),
4239
default=dict,
4340
blank=True,
4441
help_text=_("parameters needed to perform the check"),
45-
load_kwargs={"object_pairs_hook": OrderedDict},
46-
dump_kwargs={"indent": 4},
4742
)
4843

4944
class Meta:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django on 2026-02-23
2+
# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("check", "0011_check_active_object_checks_idx"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="check",
15+
name="params",
16+
field=models.JSONField(
17+
blank=True,
18+
default=dict,
19+
help_text="parameters needed to perform the check",
20+
verbose_name="parameters",
21+
),
22+
),
23+
]

openwisp_monitoring/monitoring/base/models.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from django.db import IntegrityError, models
1717
from django.utils import timezone
1818
from django.utils.translation import gettext_lazy as _
19-
from jsonfield import JSONField
2019
from openwisp_notifications.signals import notify
2120
from pytz import timezone as tz
2221
from pytz import utc
@@ -91,20 +90,16 @@ class AbstractMetric(TimeStampedEditableModel):
9190
)
9291
object_id = models.CharField(max_length=36, db_index=True, blank=True, null=True)
9392
content_object = GenericForeignKey("content_type", "object_id")
94-
main_tags = JSONField(
93+
main_tags = models.JSONField(
9594
_("main tags"),
9695
default=dict,
9796
blank=True,
98-
load_kwargs={"object_pairs_hook": OrderedDict},
99-
dump_kwargs={"indent": 4},
10097
db_index=True,
10198
)
102-
extra_tags = JSONField(
99+
extra_tags = models.JSONField(
103100
_("extra tags"),
104101
default=dict,
105102
blank=True,
106-
load_kwargs={"object_pairs_hook": OrderedDict},
107-
dump_kwargs={"indent": 4},
108103
)
109104
# NULL means the health has yet to be assessed
110105
is_healthy = models.BooleanField(default=None, null=True, blank=True, db_index=True)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django on 2026-02-23
2+
# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("monitoring", "0012_migrate_signal_metrics"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="metric",
15+
name="main_tags",
16+
field=models.JSONField(
17+
blank=True,
18+
db_index=True,
19+
default=dict,
20+
verbose_name="main tags",
21+
),
22+
),
23+
migrations.AlterField(
24+
model_name="metric",
25+
name="extra_tags",
26+
field=models.JSONField(
27+
blank=True,
28+
default=dict,
29+
verbose_name="extra tags",
30+
),
31+
),
32+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django on 2026-02-23
2+
# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("sample_check", "0003_add_check_inline_permissions"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="check",
15+
name="params",
16+
field=models.JSONField(
17+
blank=True,
18+
default=dict,
19+
help_text="parameters needed to perform the check",
20+
verbose_name="parameters",
21+
),
22+
),
23+
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django on 2026-02-23
2+
# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField
3+
4+
from django.db import migrations, models
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("sample_monitoring", "0004_alter_metric_field_name"),
9+
]
10+
11+
operations = [
12+
migrations.AlterField(
13+
model_name="metric",
14+
name="main_tags",
15+
field=models.JSONField(
16+
blank=True,
17+
db_index=True,
18+
default=dict,
19+
verbose_name="main tags",
20+
),
21+
),
22+
migrations.AlterField(
23+
model_name="metric",
24+
name="extra_tags",
25+
field=models.JSONField(
26+
blank=True,
27+
default=dict,
28+
verbose_name="extra tags",
29+
),
30+
),
31+
]

0 commit comments

Comments
 (0)