mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
Moved compatibility code into compat.py
This commit is contained in:
parent
7d2b73a024
commit
8fa1b7c2b7
|
@ -41,6 +41,13 @@ except ImportError:
|
|||
uritemplate = None
|
||||
|
||||
|
||||
# async_to_sync is required for async View support
|
||||
if django.VERSION >= (3, 1):
|
||||
from asgiref.sync import async_to_sync
|
||||
else:
|
||||
async_to_sync = None
|
||||
|
||||
|
||||
# coreschema is optional
|
||||
try:
|
||||
import coreschema
|
||||
|
|
|
@ -3,7 +3,6 @@ Provides an APIView class that is the base of all views in REST framework.
|
|||
"""
|
||||
import asyncio
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import connections, models
|
||||
|
@ -15,17 +14,13 @@ from django.views.decorators.csrf import csrf_exempt
|
|||
from django.views.generic import View
|
||||
|
||||
from rest_framework import exceptions, status
|
||||
from rest_framework.compat import async_to_sync
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.schemas import DefaultSchema
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils import formatting
|
||||
|
||||
if django.VERSION >= (3, 1):
|
||||
from asgiref.sync import async_to_sync
|
||||
else:
|
||||
async_to_sync = None
|
||||
|
||||
|
||||
def get_view_name(view):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user