Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix imports for upcoming DRF version #408

Merged
merged 3 commits into from Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion requirements/testproj.txt
Expand Up @@ -3,7 +3,9 @@ Pillow>=4.3.0
django-cors-headers>=2.1.0
django-filter>=1.1.0,<2.0; python_version == "2.7"
django-filter>=1.1.0; python_version >= "3.5"
djangorestframework-camel-case>=0.2.0
#djangorestframework-camel-case>=0.2.0
# tempory replacement of broken lib
-e git+https://github.com/tfranzel/djangorestframework-camel-case.git@bd556d38fa7382acadfe91d93d92d99c663248a9#egg=djangorestframework_camel_case
djangorestframework-recursive>=0.1.2
dj-database-url>=0.4.2
user_agents>=1.1.0
Expand Down
13 changes: 11 additions & 2 deletions src/drf_yasg/generators.py
Expand Up @@ -4,14 +4,23 @@
from collections import OrderedDict, defaultdict

import uritemplate
import rest_framework
from coreapi.compat import urlparse
from rest_framework import versioning
from rest_framework.compat import URLPattern, URLResolver, get_original_route
from rest_framework.schemas.generators import EndpointEnumerator as _EndpointEnumerator
from rest_framework.schemas.generators import SchemaGenerator, endpoint_ordering, get_pk_name
from rest_framework.schemas.inspectors import get_pk_description
from rest_framework.schemas.generators import endpoint_ordering, get_pk_name

from rest_framework.settings import api_settings

from packaging.version import Version
if Version(rest_framework.__version__) < Version('3.10'):
from rest_framework.schemas.generators import SchemaGenerator
from rest_framework.schemas.inspectors import get_pk_description
else:
from rest_framework.schemas import SchemaGenerator
from rest_framework.schemas.utils import get_pk_description

from . import openapi
from .app_settings import swagger_settings
from .errors import SwaggerGenerationError
Expand Down
7 changes: 6 additions & 1 deletion testproj/snippets/serializers.py
@@ -1,8 +1,13 @@
import rest_framework
from decimal import Decimal

from django.contrib.auth import get_user_model
from packaging.version import Version
if Version(rest_framework.__version__) < Version('3.10'):
from rest_framework.compat import MaxLengthValidator, MinValueValidator
else:
from django.core.validators import MaxLengthValidator, MinValueValidator
from rest_framework import serializers
from rest_framework.compat import MaxLengthValidator, MinValueValidator

from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet, SnippetViewer

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Expand Up @@ -9,6 +9,7 @@ envlist =
py27-django111-drf{38,39},
py{35,36}-django{111,21,22}-drf{38,39},
py37-django{21,22}-drf{38,39},
py37-django{21,22}-drf310,
djmaster, lint, docs

[testenv:.package]
Expand All @@ -23,6 +24,7 @@ deps =

drf38: djangorestframework>=3.8,<3.9
drf39: djangorestframework>=3.9,<3.10
drf310: djangorestframework>=3.10

typing: typing>=3.6.6

Expand Down