diff --git a/binder/models.py b/binder/models.py index 993482f0..762f60fc 100644 --- a/binder/models.py +++ b/binder/models.py @@ -11,7 +11,7 @@ from django import forms from django.db import models from django.db.models.fields.files import FieldFile, FileField -from django.contrib.postgres.fields import CITextField, ArrayField, JSONField, DateTimeRangeField as DTRangeField +from django.contrib.postgres.fields import CITextField, ArrayField, DateTimeRangeField as DTRangeField from django.core import checks from django.core.files.base import File, ContentFile from django.core.files.images import ImageFile @@ -395,7 +395,7 @@ def clean_value(self, qualifier, v): class JSONFieldFilter(FieldFilter): - fields = [JSONField] + fields = [models.JSONField] # TODO: Element or path-based lookup is not supported yet allowed_qualifiers = [None, 'contains', 'contained_by', 'has_key', 'has_any_keys', 'has_keys', 'isnull'] diff --git a/binder/plugins/my_filters/migrations/0002_migrate_jsonfield.py b/binder/plugins/my_filters/migrations/0002_migrate_jsonfield.py new file mode 100644 index 00000000..89310e49 --- /dev/null +++ b/binder/plugins/my_filters/migrations/0002_migrate_jsonfield.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('my_filters', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='MyFilter', + name='params', + field=models.JSONField(), + ), + ] diff --git a/binder/plugins/my_filters/models.py b/binder/plugins/my_filters/models.py index 89c605b6..73c277ed 100644 --- a/binder/plugins/my_filters/models.py +++ b/binder/plugins/my_filters/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.contrib.postgres.fields import JSONField from django.conf import settings from ...models import BinderModel @@ -13,7 +12,7 @@ class MyFilter(BinderModel): ) view = models.TextField() name = models.TextField() - params = JSONField() + params = models.JSONField() default = models.BooleanField(default=False) class Meta(BinderModel.Meta): diff --git a/tests/testapp/models/feeding_schedule.py b/tests/testapp/models/feeding_schedule.py index a0fa37d7..f907fce7 100644 --- a/tests/testapp/models/feeding_schedule.py +++ b/tests/testapp/models/feeding_schedule.py @@ -1,4 +1,4 @@ -from django.contrib.postgres.fields import ArrayField, JSONField +from django.contrib.postgres.fields import ArrayField from django.db import models from binder.models import BinderModel, ChoiceEnum @@ -8,7 +8,7 @@ class FeedingSchedule(BinderModel): animal = models.OneToOneField('Animal', on_delete=models.CASCADE, related_name='feeding_schedule') description = models.TextField(blank=True, null=True) foods = ArrayField(models.TextField(choices=FOODS.choices()), blank=True, default=[]) - schedule_details = JSONField(blank=True, default=[]) + schedule_details = models.JSONField(blank=True, default=[]) def __str__(self): return 'feeding schedule %d: %s (for %s)' % (self.pk, self.description, self.animal)