-
-
Notifications
You must be signed in to change notification settings - Fork 173
[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
base: master
Are you sure you want to change the base?
Changes from 2 commits
26a7726
d5e8d0f
951dc5e
2b3ab89
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,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", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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( | ||
|
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, | ||
| ) | ||
| extra_tags = JSONField( | ||
| extra_tags = models.JSONField( | ||
|
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}, | ||
| ) | ||
|
Comment on lines
+93
to
103
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for any remaining imports of the third-party jsonfield package
echo "=== Remaining jsonfield imports ==="
rg -n 'from jsonfield' --type=py
rg -n 'import jsonfield' --type=py
echo ""
echo "=== jsonfield in dependency files ==="
rg -n 'jsonfield' -g 'setup.*' -g 'pyproject.toml' -g 'requirements*' -g 'Pipfile*'Repository: openwisp/openwisp-monitoring Length of output: 527 Remove The original
These migrations will fail when executed because the 🤖 Prompt for AI Agents |
||
| # 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,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", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # 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", | ||
| ), | ||
|
Comment on lines
+16
to
+21
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, | ||
| 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