From 35c4a0450407e3ada16a958c0ff5d1e7642910c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Sun, 15 May 2022 11:35:46 +0200
Subject: [PATCH 2/2] general: switch to django postgresql json field (#65265)

---
 .../fargo/migrations/0001_squashed_0017_auto_20180331_1532.py | 4 ++--
 fargo/fargo/migrations/0003_auto_20150924_1056.py             | 4 ++--
 fargo/fargo/models.py                                         | 4 ++--
 requirements.txt                                              | 1 -
 setup.py                                                      | 1 -
 5 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/fargo/fargo/migrations/0001_squashed_0017_auto_20180331_1532.py b/fargo/fargo/migrations/0001_squashed_0017_auto_20180331_1532.py
index 244e5c5..023c15b 100644
--- a/fargo/fargo/migrations/0001_squashed_0017_auto_20180331_1532.py
+++ b/fargo/fargo/migrations/0001_squashed_0017_auto_20180331_1532.py
@@ -3,8 +3,8 @@
 import datetime
 
 import django.db.models.deletion
-import jsonfield.fields
 from django.conf import settings
+from django.contrib.postgres.fields import JSONField
 from django.db import migrations, models
 from django.utils.timezone import utc
 
@@ -124,7 +124,7 @@ class Migration(migrations.Migration):
                     models.CharField(max_length=128, null=True, verbose_name='content hash', blank=True),
                 ),
                 ('document_type', models.CharField(max_length=256, verbose_name='document type')),
-                ('data', jsonfield.fields.JSONField(null=True, verbose_name='data')),
+                ('data', JSONField(null=True, verbose_name='data', default=dict)),
                 ('start', models.DateField(verbose_name='start date')),
                 ('end', models.DateField(verbose_name='end date')),
                 ('creator', models.CharField(max_length=256, verbose_name='creator')),
diff --git a/fargo/fargo/migrations/0003_auto_20150924_1056.py b/fargo/fargo/migrations/0003_auto_20150924_1056.py
index 9937799..2b884f5 100644
--- a/fargo/fargo/migrations/0003_auto_20150924_1056.py
+++ b/fargo/fargo/migrations/0003_auto_20150924_1056.py
@@ -1,7 +1,7 @@
 import datetime
 
-import jsonfield.fields
 from django.conf import settings
+from django.contrib.postgres.fields import JSONField
 from django.db import migrations, models
 from django.utils.timezone import utc
 
@@ -48,7 +48,7 @@ class Migration(migrations.Migration):
                     models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True),
                 ),
                 ('document_type', models.CharField(max_length=256, verbose_name='document type')),
-                ('data', jsonfield.fields.JSONField(null=True, verbose_name='data')),
+                ('data', JSONField(null=True, verbose_name='data', default=dict)),
                 ('start', models.DateField(verbose_name='start date')),
                 ('end', models.DateField(verbose_name='end date')),
                 ('creator', models.CharField(max_length=256, verbose_name='creator')),
diff --git a/fargo/fargo/models.py b/fargo/fargo/models.py
index 903706a..4f31bb7 100644
--- a/fargo/fargo/models.py
+++ b/fargo/fargo/models.py
@@ -22,6 +22,7 @@ import subprocess
 import threading
 
 from django.conf import settings
+from django.contrib.postgres.fields import JSONField
 from django.core.files.storage import default_storage
 from django.db import models
 from django.db.models.signals import post_delete, post_save
@@ -32,7 +33,6 @@ from django.utils.html import format_html
 from django.utils.http import urlquote
 from django.utils.text import slugify
 from django.utils.translation import ugettext_lazy as _
-from jsonfield import JSONField
 from sorl.thumbnail import delete, get_thumbnail
 from sorl.thumbnail.conf import settings as thumbnail_settings
 
@@ -125,7 +125,7 @@ class Validation(models.Model):
     content_hash = models.CharField(max_length=128, verbose_name=_('content hash'), blank=True, null=True)
     origin = models.ForeignKey(Origin, verbose_name=_('origin'), null=True, on_delete=models.CASCADE)
     document_type = models.CharField(max_length=256, verbose_name=_('document type'))
-    data = JSONField(null=True, verbose_name=_('data'))
+    data = JSONField(null=True, verbose_name=_('data'), default=dict)
     start = models.DateField(verbose_name=_('start date'))
     end = models.DateField(verbose_name=_('end date'))
     creator = models.CharField(max_length=256, verbose_name=_('creator'))
diff --git a/requirements.txt b/requirements.txt
index 3b3aecc..762c5ce 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,4 @@
 django>=1.7,<1.9
 django-tables2<1.1
-django-jsonfield >= 0.9.3
 djangorestframework>=3.3,<3.10
 file-magic
diff --git a/setup.py b/setup.py
index 47419b5..2281393 100755
--- a/setup.py
+++ b/setup.py
@@ -110,7 +110,6 @@ setup(
         'django>=2.2,<2.3',
         'gadjo',
         'django-tables2>=1.5,<2.2',
-        'django-jsonfield >= 0.9.3',
         'django-filter>1,<2.5',
         'djangorestframework>=3.4',
         'file-magic',
-- 
2.36.1

