diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-05-30 22:13:58 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-05-30 23:10:30 +0100 |
| commit | 33ea472f6924480eb8708bc6d0ac90b9f742ba68 (patch) | |
| tree | 2ca1f92c94638db440e3e23a30bd9a67ca34f8f3 /tests/postgres_tests/models.py | |
| parent | 74fe4428e51030cbed768083489f0497f4453c17 (diff) | |
Fixed #24604 -- Added JSONField to contrib.postgres.
Diffstat (limited to 'tests/postgres_tests/models.py')
| -rw-r--r-- | tests/postgres_tests/models.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index aafd529443..329a91c951 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -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()) |
