【发布时间】:2017-10-25 12:07:21
【问题描述】:
在我的基于 DRF 的应用程序中使用 Django Rest Auth 进行身份验证。问题是,当我添加 URL 版本控制时,注销 URL 不起作用。
呼叫:/v1/rest-auth/logout/ (POST)
抛出错误:TypeError: post() got an unexpected keyword argument 'version'
urls.py:
URL_VERSION = r'^(?P<version>v[1])'
url(f'{URL_VERSION}/rest-auth/', include('rest_auth.urls'))
其他端点,例如通过 /v1/rest-auth/login/ 登录无论有无 URL_VERSION 都可以正常工作。
我可能会错过什么?
【问题讨论】:
-
在第二行,您实际上是在使用
url(f还是这里只是一个错字? -
它实际上是一个
f。它来自 python3.6f strings。链接:docs.python.org/3/whatsnew/3.6.html。示例实现在这里:github.com/limdauto/drf_openapi/blob/master/examples/examples/…
标签: django-rest-framework django-rest-auth