diff --git a/openwisp_monitoring/check/base/models.py b/openwisp_monitoring/check/base/models.py index ed1af76f4..100633bf2 100644 --- a/openwisp_monitoring/check/base/models.py +++ b/openwisp_monitoring/check/base/models.py @@ -1,12 +1,9 @@ -from collections import OrderedDict - from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from django.utils.functional import cached_property from django.utils.module_loading import import_string from django.utils.translation import gettext_lazy as _ -from jsonfield import JSONField from openwisp_utils.base import TimeStampedEditableModel @@ -37,13 +34,11 @@ class AbstractCheck(TimeStampedEditableModel): db_index=True, max_length=128, ) - params = JSONField( + params = models.JSONField( _("parameters"), default=dict, blank=True, help_text=_("parameters needed to perform the check"), - load_kwargs={"object_pairs_hook": OrderedDict}, - dump_kwargs={"indent": 4}, ) class Meta: diff --git a/openwisp_monitoring/check/migrations/0012_replace_jsonfield_with_django_builtin.py b/openwisp_monitoring/check/migrations/0012_replace_jsonfield_with_django_builtin.py new file mode 100644 index 000000000..537e03096 --- /dev/null +++ b/openwisp_monitoring/check/migrations/0012_replace_jsonfield_with_django_builtin.py @@ -0,0 +1,23 @@ +# Generated by Django on 2026-02-23 +# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("check", "0011_check_active_object_checks_idx"), + ] + + operations = [ + migrations.AlterField( + model_name="check", + name="params", + field=models.JSONField( + blank=True, + default=dict, + help_text="parameters needed to perform the check", + verbose_name="parameters", + ), + ), + ] diff --git a/openwisp_monitoring/monitoring/base/models.py b/openwisp_monitoring/monitoring/base/models.py index 7c5c7ad92..47350d0d1 100644 --- a/openwisp_monitoring/monitoring/base/models.py +++ b/openwisp_monitoring/monitoring/base/models.py @@ -16,7 +16,6 @@ from django.db import IntegrityError, models from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from jsonfield import JSONField from openwisp_notifications.signals import notify from pytz import timezone as tz from pytz import utc @@ -91,20 +90,16 @@ class AbstractMetric(TimeStampedEditableModel): ) object_id = models.CharField(max_length=36, db_index=True, blank=True, null=True) content_object = GenericForeignKey("content_type", "object_id") - main_tags = JSONField( + main_tags = models.JSONField( _("main tags"), default=dict, blank=True, - load_kwargs={"object_pairs_hook": OrderedDict}, - dump_kwargs={"indent": 4}, db_index=True, ) - extra_tags = JSONField( + extra_tags = models.JSONField( _("extra tags"), default=dict, blank=True, - load_kwargs={"object_pairs_hook": OrderedDict}, - dump_kwargs={"indent": 4}, ) # NULL means the health has yet to be assessed is_healthy = models.BooleanField(default=None, null=True, blank=True, db_index=True) diff --git a/openwisp_monitoring/monitoring/migrations/0013_replace_jsonfield_with_django_builtin.py b/openwisp_monitoring/monitoring/migrations/0013_replace_jsonfield_with_django_builtin.py new file mode 100644 index 000000000..46f24dd9b --- /dev/null +++ b/openwisp_monitoring/monitoring/migrations/0013_replace_jsonfield_with_django_builtin.py @@ -0,0 +1,32 @@ +# Generated by Django on 2026-02-23 +# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("monitoring", "0012_migrate_signal_metrics"), + ] + + operations = [ + migrations.AlterField( + model_name="metric", + name="main_tags", + field=models.JSONField( + blank=True, + db_index=True, + default=dict, + verbose_name="main tags", + ), + ), + migrations.AlterField( + model_name="metric", + name="extra_tags", + field=models.JSONField( + blank=True, + default=dict, + verbose_name="extra tags", + ), + ), + ] diff --git a/tests/openwisp2/sample_check/migrations/0004_replace_jsonfield_with_django_builtin.py b/tests/openwisp2/sample_check/migrations/0004_replace_jsonfield_with_django_builtin.py new file mode 100644 index 000000000..7b0bd80b9 --- /dev/null +++ b/tests/openwisp2/sample_check/migrations/0004_replace_jsonfield_with_django_builtin.py @@ -0,0 +1,23 @@ +# Generated by Django on 2026-02-23 +# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("sample_check", "0003_add_check_inline_permissions"), + ] + + operations = [ + migrations.AlterField( + model_name="check", + name="params", + field=models.JSONField( + blank=True, + default=dict, + help_text="parameters needed to perform the check", + verbose_name="parameters", + ), + ), + ] diff --git a/tests/openwisp2/sample_monitoring/migrations/0005_replace_jsonfield_with_django_builtin.py b/tests/openwisp2/sample_monitoring/migrations/0005_replace_jsonfield_with_django_builtin.py new file mode 100644 index 000000000..e693398ba --- /dev/null +++ b/tests/openwisp2/sample_monitoring/migrations/0005_replace_jsonfield_with_django_builtin.py @@ -0,0 +1,32 @@ +# Generated by Django on 2026-02-23 +# Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("sample_monitoring", "0004_alter_metric_field_name"), + ] + + operations = [ + migrations.AlterField( + model_name="metric", + name="main_tags", + field=models.JSONField( + blank=True, + db_index=True, + default=dict, + verbose_name="main tags", + ), + ), + migrations.AlterField( + model_name="metric", + name="extra_tags", + field=models.JSONField( + blank=True, + default=dict, + verbose_name="extra tags", + ), + ), + ]