Move postgres_fields import out of compat.py

This commit is contained in:
Levi Payne 2017-10-04 20:45:27 -04:00
parent de202e4acd
commit 99d120b2e4
2 changed files with 7 additions and 10 deletions

View File

@ -115,15 +115,6 @@ def _resolve_model(obj):
raise ValueError("{0} is not a Django model".format(obj))
# TODO: Remove
# contrib.postgres only supported from 1.8 onwards.
try:
from django.contrib.postgres import fields as postgres_fields
except ImportError:
postgres_fields = None
# TODO: Remove
# JSONField is only supported from 1.9 onwards
try:

View File

@ -28,7 +28,7 @@ from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from rest_framework.compat import JSONField as ModelJSONField
from rest_framework.compat import postgres_fields, set_many, unicode_to_repr
from rest_framework.compat import set_many, unicode_to_repr
from rest_framework.exceptions import ErrorDetail, ValidationError
from rest_framework.fields import get_error_detail, set_value
from rest_framework.settings import api_settings
@ -46,6 +46,12 @@ from rest_framework.validators import (
UniqueTogetherValidator
)
try:
from django.contrib.postgres import fields as postgres_fields
except ImportError:
postgres_fields = None
# Note: We do the following so that users of the framework can use this style:
#
# example_field = serializers.CharField(...)