gpt4 book ai didi

python - 无法从 'detail_route' 导入名称 'rest_framework.decorators'

转载 作者:行者123 更新时间:2023-11-28 21:31:56 27 4
gpt4 key购买 nike

我正在尝试运行 longclaw,但出现错误

$ python manage.py makemigrations catalog home

Traceback (most recent call last):
[...]
File "/lib/python3.7/site-packages/longclaw/basket/api.py", line 1, in <module>
from rest_framework.decorators import detail_route, list_route
ImportError: cannot import name 'detail_route' from 'rest_framework.decorators'

最佳答案

这是因为 detail_route 已从 DRF 3.8 中弃用。你可以查看他们的change-log以及。或者,您可以使用 actions 装饰器。例如:

from rest_framework.decorators import action

@action(detail=True, methods=['post'])
def set_password(self, request, pk=None):
....

关于python - 无法从 'detail_route' 导入名称 'rest_framework.decorators',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57319224/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com