1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #24001 -- Added range fields for PostgreSQL.

Added support for PostgreSQL range types to contrib.postgres.

- 5 new model fields
- 4 new form fields
- New validators
- Uses psycopg2's range type implementation in python
This commit is contained in:
Marc Tamlyn
2015-01-10 16:14:20 +00:00
parent 916e38802f
commit 48ad288679
15 changed files with 986 additions and 6 deletions

View File

@@ -92,3 +92,26 @@ class Migration(migrations.Migration):
bases=None,
),
]
pg_92_operations = [
migrations.CreateModel(
name='RangesModel',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('ints', django.contrib.postgres.fields.IntegerRangeField(null=True, blank=True)),
('bigints', django.contrib.postgres.fields.BigIntegerRangeField(null=True, blank=True)),
('floats', django.contrib.postgres.fields.FloatRangeField(null=True, blank=True)),
('timestamps', django.contrib.postgres.fields.DateTimeRangeField(null=True, blank=True)),
('dates', django.contrib.postgres.fields.DateRangeField(null=True, blank=True)),
],
options={
},
bases=(models.Model,),
),
]
def apply(self, project_state, schema_editor, collect_sql=False):
PG_VERSION = schema_editor.connection.pg_version
if PG_VERSION >= 90200:
self.operations = self.operations + self.pg_92_operations
return super(Migration, self).apply(project_state, schema_editor, collect_sql)