Browse Source

Fix imports for DRF 3.10 (#408)

Fixes #410
Fixes #411
tags/1.16.1
tfranzel 4 months ago
parent
commit
1904b0499e
4 changed files with 22 additions and 4 deletions
  1. 3
    1
      requirements/testproj.txt
  2. 11
    2
      src/drf_yasg/generators.py
  3. 6
    1
      testproj/snippets/serializers.py
  4. 2
    0
      tox.ini

+ 3
- 1
requirements/testproj.txt View File

@@ -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

+ 11
- 2
src/drf_yasg/generators.py View File

@@ -4,14 +4,23 @@ import re
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

+ 6
- 1
testproj/snippets/serializers.py View File

@@ -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


+ 2
- 0
tox.ini View File

@@ -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]
@@ -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


Loading…
Cancel
Save