diff --git a/django/contrib/postgres/apps.py b/django/contrib/postgres/apps.py index 2ad6aaefc8..897cb09d3e 100644 --- a/django/contrib/postgres/apps.py +++ b/django/contrib/postgres/apps.py @@ -18,6 +18,11 @@ class PostgresConfig(AppConfig): 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', }) if conn.connection is not None: register_type_handlers(conn) diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 46ff112dba..c744320917 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -123,8 +123,8 @@ Minor features operation installs the ``btree_gist`` extension to add support for operator classes that aren't built-in. -* :djadmin:`inspectdb` can now introspect ``JSONField`` - (``django.contrib.postgres`` must be in ``INSTALLED_APPS``). +* :djadmin:`inspectdb` can now introspect ``JSONField`` and various + ``RangeField``\s (``django.contrib.postgres`` must be in ``INSTALLED_APPS``). :mod:`django.contrib.redirects` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/postgres_tests/test_introspection.py b/tests/postgres_tests/test_introspection.py index 1058a1656b..a63f08db50 100644 --- a/tests/postgres_tests/test_introspection.py +++ b/tests/postgres_tests/test_introspection.py @@ -24,3 +24,15 @@ class InspectDBTests(PostgreSQLTestCase): 'postgres_tests_jsonmodel', ['field = django.contrib.postgresql.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)', + ], + )