mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Used a database feature to prevent the jsonb test model from being migrated.
Thanks Tim for the review.
This commit is contained in:
parent
e07b18252b
commit
32c0d823e5
4 changed files with 19 additions and 42 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue