From 0eb71b85bf7705f7418fae2572fe1960dd514300 Mon Sep 17 00:00:00 2001 From: Alasdair Nicol Date: Mon, 9 Apr 2018 16:46:31 +0000 Subject: [PATCH] [2.0.x] Fixed #29307 -- Fixed inspectdb import paths for django.contrib.postgres fields. Thanks erindy for the report. Backport of 65c44a5c1d5412d402af19480e3c1c3e3e88893a from master --- django/contrib/postgres/apps.py | 12 ++++++------ docs/releases/2.0.5.txt | 3 ++- tests/postgres_tests/test_introspection.py | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/django/contrib/postgres/apps.py b/django/contrib/postgres/apps.py index 897cb09d3e..1ab5074f19 100644 --- a/django/contrib/postgres/apps.py +++ b/django/contrib/postgres/apps.py @@ -17,12 +17,12 @@ class PostgresConfig(AppConfig): for conn in connections.all(): if conn.vendor == 'postgresql': conn.introspection.data_types_reverse.update({ - 3802: 'django.contrib.postgresql.fields.JSONField', - 3904: 'django.contrib.postgresql.fields.IntegerRangeField', - 3906: 'django.contrib.postgresql.fields.FloatRangeField', - 3910: 'django.contrib.postgresql.fields.DateTimeRangeField', - 3912: 'django.contrib.postgresql.fields.DateRangeField', - 3926: 'django.contrib.postgresql.fields.BigIntegerRangeField', + 3802: 'django.contrib.postgres.fields.JSONField', + 3904: 'django.contrib.postgres.fields.IntegerRangeField', + 3906: 'django.contrib.postgres.fields.FloatRangeField', + 3910: 'django.contrib.postgres.fields.DateTimeRangeField', + 3912: 'django.contrib.postgres.fields.DateRangeField', + 3926: 'django.contrib.postgres.fields.BigIntegerRangeField', }) if conn.connection is not None: register_type_handlers(conn) diff --git a/docs/releases/2.0.5.txt b/docs/releases/2.0.5.txt index bba17eea9f..c7a7a84d9e 100644 --- a/docs/releases/2.0.5.txt +++ b/docs/releases/2.0.5.txt @@ -9,4 +9,5 @@ Django 2.0.5 fixes several bugs in 2.0.4. Bugfixes ======== -* ... +* Corrected the import paths that ``inspectdb`` generates for + ``django.contrib.postgres`` fields (:ticket:`29307`). diff --git a/tests/postgres_tests/test_introspection.py b/tests/postgres_tests/test_introspection.py index b17d9fc81a..683292ddec 100644 --- a/tests/postgres_tests/test_introspection.py +++ b/tests/postgres_tests/test_introspection.py @@ -24,17 +24,17 @@ class InspectDBTests(PostgreSQLTestCase): def test_json_field(self): self.assertFieldsInModel( 'postgres_tests_jsonmodel', - ['field = django.contrib.postgresql.fields.JSONField(blank=True, null=True)'], + ['field = django.contrib.postgres.fields.JSONField(blank=True, null=True)'], ) def test_range_fields(self): self.assertFieldsInModel( 'postgres_tests_rangesmodel', [ - 'ints = django.contrib.postgresql.fields.IntegerRangeField(blank=True, null=True)', - 'bigints = django.contrib.postgresql.fields.BigIntegerRangeField(blank=True, null=True)', - 'floats = django.contrib.postgresql.fields.FloatRangeField(blank=True, null=True)', - 'timestamps = django.contrib.postgresql.fields.DateTimeRangeField(blank=True, null=True)', - 'dates = django.contrib.postgresql.fields.DateRangeField(blank=True, null=True)', + 'ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, null=True)', + 'bigints = django.contrib.postgres.fields.BigIntegerRangeField(blank=True, null=True)', + 'floats = django.contrib.postgres.fields.FloatRangeField(blank=True, null=True)', + 'timestamps = django.contrib.postgres.fields.DateTimeRangeField(blank=True, null=True)', + 'dates = django.contrib.postgres.fields.DateRangeField(blank=True, null=True)', ], )