【发布时间】:2022-02-12 23:18:23
【问题描述】:
API 端点是这样的,在 django 后端 /accounts/id/uuid:pk/some_action/
在模型中它被定义为
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
apiview 接受请求和 pk,uuid 为 pk。
@api_view(['PUT'])
def some_action(request, pk):
当我使用 uuid 发出请求时,它给了我以下错误
Not Found: /accounts/user/{id}/some-action/
[12/Feb/2022 18:41:28] "PUT /accounts/id/%7Bid%7D/some-action/ HTTP/1.1" 404 4930
在 Postman 中,我像这样配置网址 /accounts/id/{id}/some-action/
那么传递 uuid 可能会出现什么问题?
【问题讨论】:
标签: django django-rest-framework postman django-urls uuid