mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user