diff --git a/drf_extra_fields/compat.py b/drf_extra_fields/compat.py index 591ae08..6ed80cd 100644 --- a/drf_extra_fields/compat.py +++ b/drf_extra_fields/compat.py @@ -1,10 +1,19 @@ +import django + try: from django.contrib.postgres.fields import FloatRangeField except ImportError: FloatRangeField = None try: - from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange + if django.VERSION >= (4, 2): + try: + from psycopg.types.range import DateRange, NumericRange + from psycopg.types.range import TimestamptzRange as DateTimeTZRange + except ImportError: + from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange + else: + from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange except ImportError: DateRange = None DateTimeTZRange = None diff --git a/requirements_dev.txt b/requirements_dev.txt index 5f9cc80..4e56cfc 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,4 +2,5 @@ Pillow >= 6.2.1 pytest-django pytest-cov psycopg2-binary +psycopg[binary] flake8 diff --git a/tox.ini b/tox.ini index 0da60b7..58384c5 100644 --- a/tox.ini +++ b/tox.ini @@ -9,8 +9,9 @@ python = [tox] envlist = flake8, - py{37,38,39,310}-drf3-django{22,32} - py{38,39,310,311}-drf3-django{40,41,42} + py{37,38,39,310}-drf3-django{22,32}-psycopg2 + py{38,39,310,311}-drf3-django{40,41}-psycopg2 + py{38,39,310,311}-drf3-django42-psycopg{2,3} [testenv] deps = @@ -20,7 +21,12 @@ deps = django41: Django>=4.1,<4.2 django42: Django>=4.2,<4.3 drf3: djangorestframework>=3 - -r requirements_dev.txt + psycopg2: psycopg2-binary + psycopg3: psycopg[binary] + + Pillow >= 6.2.1 + pytest-django + pytest-cov commands = py.test {posargs} --cov-report=xml --cov