Skip to content

Conversation

Eeshu-Yadav
Copy link

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #363.

Description of Changes

Changes Made:

  1. Model Field Update:

    • Replaced jsonfield.fields.JSONField with Django's models.JSONField in openwisp_notifications/base/notifications.py
    • Removed the third-party import
  2. Settings Simplification:

    • Removed USE_JSONFIELD setting from CONFIG_DEFAULTS as it's no longer needed
    • Django's JSONField always supports JSON data storage
  3. Handler Logic Optimization:

    • Simplified conditional logic in openwisp_notifications/handlers.py
    • Removed EXTRA_DATA variable that was tied to the USE_JSONFIELD setting
    • Changed from if kwargs and EXTRA_DATA: to if kwargs: for cleaner code
  4. Database Migration:

    • Added migration 0010_replace_jsonfield_with_django_builtin.py to safely migrate existing data

- Replace jsonfield.fields.JSONField with Django's models.JSONField in notifications.py
- Remove jsonfield>=2.1.0 dependency from requirements.txt
- Remove USE_JSONFIELD setting as it's no longer needed with Django's JSONField
- Simplify handler logic by removing EXTRA_DATA conditional checks
- Add migration to convert existing JSONField to Django's built-in version
- Ensures data preservation during migration process

Fixes openwisp#363
@Eeshu-Yadav Eeshu-Yadav force-pushed the issues/363-replace-jsonfield-with-django-builtin branch from 4567689 to 97419b3 Compare August 14, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[change:notifications] Replace thirdparty JSONField with Django built in JSONField

1 participant