Python 无法使用来自drf扩展的混合

Python 无法使用来自drf扩展的混合,python,django-models,django-rest-framework,drf-extensions,Python,Django Models,Django Rest Framework,Drf Extensions,我已经安装了drf扩展并将其导入到我的视图中。在那之后,我开始低于异常,我无法确定这一问题的根本原因。谁能解释一下,这里出了什么问题 > python .\manage.py runserver Watching for file changes with StatReloader Performing system checks... Exception in thread django-main-thread: Traceback (most recent call last):

我已经安装了drf扩展并将其导入到我的视图中。在那之后,我开始低于异常,我无法确定这一问题的根本原因。谁能解释一下,这里出了什么问题

> python .\manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework\settings.py", line 177, in import_from_string
    return import_string(val)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\utils.py", line 6, in <module>
    from rest_framework_extensions.key_constructor.constructors import (
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\key_constructor\constructors.py", line 4, in <module>
    from rest_framework_extensions.key_constructor import bits
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\key_constructor\bits.py", line 3, in <module>
    from django.db.models.sql.datastructures import EmptyResultSet
ImportError: cannot import name 'EmptyResultSet' from 'django.db.models.sql.datastructures'

 (C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\db\models\sql\datastructures.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = checks.run_checks(
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\urls\resolvers.py", line 408, in check
    for pattern in self.url_patterns:
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\gknath\Desktop\python-django\testing_new_backend_model_modp\projects\urls.py", line 5, in <module>
    from .api import router
  File "C:\Users\gknath\Desktop\python-django\testing_new_backend_model_modp\projects\api.py", line 2, in <module>
    from api.views import FactorViewSet, ProjectViewSet, FactorViewSet
  File "C:\Users\gknath\Desktop\python-django\testing_new_backend_model_modp\api\views.py", line 3, in <module>
    from rest_framework_extensions.mixins import NestedViewSetMixin
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\mixins.py", line 1, in <module>
    from rest_framework_extensions.cache.mixins import CacheResponseMixin
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\cache\mixins.py", line 5, in <module>
    class BaseCacheResponseMixin:
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework_extensions\cache\mixins.py", line 8, in BaseCacheResponseMixin
    object_cache_key_func = extensions_api_settings.DEFAULT_OBJECT_CACHE_KEY_FUNC
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework\settings.py", line 225, in __getattr__
    val = perform_import(val, attr)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework\settings.py", line 166, in perform_import
    return import_from_string(val, setting_name)
  File "C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\rest_framework\settings.py", line 180, in import_from_string
    raise ImportError(msg)
ImportError: Could not import 'rest_framework_extensions.utils.default_object_cache_key_func' for API setting 'DEFAULT_OBJECT_CACHE_KEY_FUNC'. ImportError: cannot import name 'EmptyResultSet' from 'django.db.models.sql.datastructures' (C:\Users\gknath\Desktop\python-django\django-models-rest\venv\lib\site-packages\django\db\models\sql\datastructures.py).
>python。\manage.py运行服务器
使用StatReloader监视文件更改
正在执行系统检查。。。
线程django主线程中出现异常:
回溯(最近一次呼叫最后一次):
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\settings.py”,第177行,从字符串导入
返回导入字符串(val)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\utils\module\u loading.py”,第17行,导入字符串
模块=导入模块(模块路径)
文件“C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\importlib\\uuuuuu init\uuuuuu.py”,第127行,在导入模块中
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“”,第1014行,在\u gcd\u导入中
文件“”,第991行,在“查找”和“加载”中
文件“”,第975行,在“查找”和“加载”中解锁
文件“”,第671行,在\u加载\u解锁
exec_模块中第783行的文件“”
文件“”,第219行,在“调用”中,删除了“帧”
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\utils.py”,第6行,在
从rest\u framework\u extensions.key\u constructor.constructor导入(
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\key\u constructor\constructors.py”,第4行,在
从rest\u framework\u extensions.key\u构造函数导入位
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\key\u constructor\bits.py”,第3行,在
从django.db.models.sql.datastructures导入EmptyResultSet
ImportError:无法从“django.db.models.sql.datastructures”导入名称“EmptyResultSet”
(C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\db\models\sql\datastructures.py)
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\threading.py”,第932行,位于\u bootstrap\u inner中
self.run()
文件“C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\threading.py”,第870行,正在运行
自我目标(*自我参数,**自我参数)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\utils\autoreload.py”,第53行,在包装器中
fn(*args,**kwargs)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\core\management\commands\runserver.py”,第118行,在内部运行
self.check(display\u num\u errors=True)
检查文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\core\management\base.py”,第392行
所有问题=检查。运行检查(
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\core\checks\registry.py”,第70行,运行检查
新建错误=检查(应用程序配置=应用程序配置,数据库=数据库)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\core\checks\url.py”,第13行,在check\u url\u config中
返回检查\u分解器(分解器)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\core\checks\url.py”,第23行,在check\u解析器中
返回检查方法()
检查文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\url\resolvers.py”第408行
对于self.url_模式中的模式:
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\utils\functional.py”,第48行,在__
res=instance.\uuuu dict\uuuu[self.name]=self.func(实例)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\url\resolvers.py”,第589行,url\U模式
patterns=getattr(self.urlconf_模块,“urlpatterns”,self.urlconf_模块)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\utils\functional.py”,第48行,在__
res=instance.\uuuu dict\uuuu[self.name]=self.func(实例)
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\django\url\resolvers.py”,第582行,在urlconf_模块中
返回导入_模块(self.urlconf_名称)
文件“C:\Users\gknath\AppData\Local\Programs\Python\Python38-32\lib\importlib\\uuuuuu init\uuuuuu.py”,第127行,在导入模块中
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“”,第1014行,在\u gcd\u导入中
文件“”,第991行,在“查找”和“加载”中
文件“”,第975行,在“查找”和“加载”中解锁
文件“”,第671行,在\u加载\u解锁
exec_模块中第783行的文件“”
文件“”,第219行,在“调用”中,删除了“帧”
文件“C:\Users\gknath\Desktop\python django\testing\u new\u backend\u model\modp\projects\url.py”,第5行,在
从.api导入路由器
文件“C:\Users\gknath\Desktop\python django\testing\u new\u backend\u model\modp\projects\api.py”,第2行,在
从api.views导入FactorViewSet、ProjectViewSet、FactorViewSet
文件“C:\Users\gknath\Desktop\python django\testing\u new\u backend\u model\u modp\api\views.py”,第3行,在
从rest_framework_extensions.mixin导入NestedViewSetMixin
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\mixins.py”,第1行,在
从rest\u framework\u extensions.cache.mixin导入CacheResponseMixin
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\cache\mixins.py”,第5行,在
类BaseCacheResponseMixin:
文件“C:\Users\gknath\Desktop\python django\django models rest\venv\lib\site packages\rest\u framework\u extensions\cache\mix
pip install -U git+git://github.com/chibisov/drf-extensions.git@8001a440c7322be26bbe2d16f3a334a8b0b5860b