[models] Replace thirdparty JSONField with Django built-in JSONField #1111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Reference to Existing Issue
Closes #1061.
Description of Changes
This PR replaces the third-party
jsonfield
package with Django's built-inJSONField
across all OpenWISP controller models to modernize the codebase and remove dependency on an unmaintained package.Changes Made:
Updated 6 model files to use
django.db.models.JSONField
instead of third-partyjsonfield.JSONField
:openwisp_controller/config/base/base.py
openwisp_controller/config/base/config.py
openwisp_controller/config/base/device_group.py
openwisp_controller/config/base/multitenancy.py
openwisp_controller/config/base/template.py
openwisp_controller/connection/base/models.py
Created 2 migration files to safely alter field types:
openwisp_controller/config/migrations/0061_replace_jsonfield_with_django_builtin.py
openwisp_controller/connection/migrations/0010_replace_jsonfield_with_django_builtin.py
Removed jsonfield-specific parameters (
load_kwargs
,dump_kwargs
) that are not supported by Django's JSONFieldFixed code quality issues by removing unused imports and duplicate imports
Technical Details:
JSONField
handles JSON serialization internally without needing external parametersload_kwargs={"object_pairs_hook": collections.OrderedDict}
is no longer needed as Python 3.7+ dicts maintain insertion orderdump_kwargs={"indent": 4}
formatting should be handled at the serialization/display layer, not the model level