Skip to content

Commit 67f78c1

Browse files
gsvrPierre Chiquet
authored andcommitted
Import coreapi from rest_framework.compat, not directly. (encode#5921)
1 parent 965ba91 commit 67f78c1

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

rest_framework/authtoken/views.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import coreapi
2-
import coreschema
31
from rest_framework import parsers, renderers
42
from rest_framework.authtoken.models import Token
53
from rest_framework.authtoken.serializers import AuthTokenSerializer
4+
from rest_framework.compat import coreapi, coreschema
65
from rest_framework.response import Response
76
from rest_framework.schemas import ManualSchema
87
from rest_framework.views import APIView
@@ -14,29 +13,30 @@ class ObtainAuthToken(APIView):
1413
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
1514
renderer_classes = (renderers.JSONRenderer,)
1615
serializer_class = AuthTokenSerializer
17-
schema = ManualSchema(
18-
fields=[
19-
coreapi.Field(
20-
name="username",
21-
required=True,
22-
location='form',
23-
schema=coreschema.String(
24-
title="Username",
25-
description="Valid username for authentication",
16+
if coreapi is not None and coreschema is not None:
17+
schema = ManualSchema(
18+
fields=[
19+
coreapi.Field(
20+
name="username",
21+
required=True,
22+
location='form',
23+
schema=coreschema.String(
24+
title="Username",
25+
description="Valid username for authentication",
26+
),
2627
),
27-
),
28-
coreapi.Field(
29-
name="password",
30-
required=True,
31-
location='form',
32-
schema=coreschema.String(
33-
title="Password",
34-
description="Valid password for authentication",
28+
coreapi.Field(
29+
name="password",
30+
required=True,
31+
location='form',
32+
schema=coreschema.String(
33+
title="Password",
34+
description="Valid password for authentication",
35+
),
3536
),
36-
),
37-
],
38-
encoding="application/json",
39-
)
37+
],
38+
encoding="application/json",
39+
)
4040

4141
def post(self, request, *args, **kwargs):
4242
serializer = self.serializer_class(data=request.data,

tests/test_renderers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from django.utils.safestring import SafeText
1515
from django.utils.translation import ugettext_lazy as _
1616

17-
import coreapi
1817
from rest_framework import permissions, serializers, status
18+
from rest_framework.compat import coreapi
1919
from rest_framework.renderers import (
2020
AdminRenderer, BaseRenderer, BrowsableAPIRenderer, DocumentationRenderer,
2121
HTMLFormRenderer, JSONRenderer, SchemaJSRenderer, StaticHTMLRenderer

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy