-
-
Notifications
You must be signed in to change notification settings - Fork 183
[change] Replace third-party JSONField with Django built-in JSONField #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
26a7726
d5e8d0f
951dc5e
2b3ab89
a1a13e1
99ddbae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Generated by Django on 2026-02-23 | ||
| # Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField | ||
|
|
||
| import django.core.serializers.json | ||
| 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, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| help_text="parameters needed to perform the check", | ||
| verbose_name="parameters", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,11 @@ | |
| from django.contrib.contenttypes.fields import GenericForeignKey | ||
| from django.contrib.contenttypes.models import ContentType | ||
| from django.core.exceptions import ObjectDoesNotExist, ValidationError | ||
| from django.core.serializers.json import DjangoJSONEncoder | ||
| from django.core.validators import MaxValueValidator | ||
| 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 +91,18 @@ 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( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add encoder=DjangoJSONEncoder to all JSONField instances (this one, extra_tags, and params in check/base/models.py). @nemesifier requested this same change on both the controller PR (openwisp/openwisp-controller#1214) and the radius PR (openwisp/openwisp-radius#619). It should be applied consistently across all openwisp repos. from django.core.serializers.json import DjangoJSONEncoder
main_tags = models.JSONField(
_("main tags"),
default=dict,
blank=True,
db_index=True,
encoder=DjangoJSONEncoder,
)The |
||
| _("main tags"), | ||
| default=dict, | ||
| blank=True, | ||
| load_kwargs={"object_pairs_hook": OrderedDict}, | ||
| dump_kwargs={"indent": 4}, | ||
| db_index=True, | ||
| encoder=DjangoJSONEncoder, | ||
| ) | ||
| extra_tags = JSONField( | ||
| extra_tags = models.JSONField( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| _("extra tags"), | ||
| default=dict, | ||
| blank=True, | ||
| load_kwargs={"object_pairs_hook": OrderedDict}, | ||
| dump_kwargs={"indent": 4}, | ||
| encoder=DjangoJSONEncoder, | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| # NULL means the health has yet to be assessed | ||
| is_healthy = models.BooleanField(default=None, null=True, blank=True, db_index=True) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Generated by Django on 2026-02-23 | ||
| # Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField | ||
|
|
||
| import django.core.serializers.json | ||
| 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, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| verbose_name="main tags", | ||
| ), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="metric", | ||
| name="extra_tags", | ||
| field=models.JSONField( | ||
| blank=True, | ||
| default=dict, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| verbose_name="extra tags", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Generated by Django on 2026-02-23 | ||
| # Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField | ||
|
|
||
| import django.core.serializers.json | ||
| 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, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| help_text="parameters needed to perform the check", | ||
| verbose_name="parameters", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Generated by Django on 2026-02-23 | ||
| # Replaces third-party jsonfield.fields.JSONField with Django's built-in models.JSONField | ||
|
|
||
| import django.core.serializers.json | ||
| 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, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| verbose_name="main tags", | ||
| ), | ||
|
Comment on lines
+17
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial
On PostgreSQL, 🤖 Prompt for AI Agents |
||
| ), | ||
| migrations.AlterField( | ||
| model_name="metric", | ||
| name="extra_tags", | ||
| field=models.JSONField( | ||
| blank=True, | ||
| default=dict, | ||
| encoder=django.core.serializers.json.DjangoJSONEncoder, | ||
| verbose_name="extra tags", | ||
| ), | ||
| ), | ||
| ] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same