mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #24604 -- Added JSONField to contrib.postgres.
This commit is contained in:
parent
74fe4428e5
commit
33ea472f69
11 changed files with 540 additions and 3 deletions
|
@ -2,7 +2,7 @@ from django.db import connection, models
|
|||
|
||||
from .fields import (
|
||||
ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
|
||||
FloatRangeField, HStoreField, IntegerRangeField,
|
||||
FloatRangeField, HStoreField, IntegerRangeField, JSONField,
|
||||
)
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ class TextFieldModel(models.Model):
|
|||
field = models.TextField()
|
||||
|
||||
|
||||
# Only create this model for databases which support it
|
||||
# Only create this model for postgres >= 9.2
|
||||
if connection.vendor == 'postgresql' and connection.pg_version >= 90200:
|
||||
class RangesModel(PostgreSQLModel):
|
||||
ints = IntegerRangeField(blank=True, null=True)
|
||||
|
@ -66,6 +66,16 @@ else:
|
|||
pass
|
||||
|
||||
|
||||
# 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)
|
||||
else:
|
||||
# create an object with this name so we don't have failing imports
|
||||
class JSONModel(object):
|
||||
pass
|
||||
|
||||
|
||||
class ArrayFieldSubclass(ArrayField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ArrayFieldSubclass, self).__init__(models.IntegerField())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue