Used a database feature to prevent the jsonb test model from being migrated.

Thanks Tim for the review.
This commit is contained in:
Simon Charette 2016-09-10 19:20:16 -04:00
parent e07b18252b
commit 32c0d823e5
4 changed files with 19 additions and 42 deletions

View file

@ -1,5 +1,5 @@
from django.core.serializers.json import DjangoJSONEncoder
from django.db import connection, models
from django.db import models
from .fields import (
ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
@ -129,15 +129,12 @@ class RangeLookupsModel(PostgreSQLModel):
date = models.DateField(blank=True, null=True)
# Only create this model for postgres >= 9.4
if connection.vendor == 'postgresql' and connection.pg_version >= 90400:
class JSONModel(models.Model):
field = JSONField(blank=True, null=True)
field_custom = JSONField(blank=True, null=True, encoder=DjangoJSONEncoder)
else:
# create an object with this name so we don't have failing imports
class JSONModel(object):
pass
class JSONModel(models.Model):
field = JSONField(blank=True, null=True)
field_custom = JSONField(blank=True, null=True, encoder=DjangoJSONEncoder)
class Meta:
required_db_features = ['has_jsonb_datatype']
class ArrayFieldSubclass(ArrayField):