EmberData
是POST
ing:
{
"data": {
"attributes": {
"name": "The project name",
"description": "The project description",
"price": 123
},
"relationships": {
"onwer": {
"data": null
}
},
"type": "projects"
}
}
而Django
(我猜是drf
)正在抱怨409 Conflict
:
{
"errors": {
"detail": "The resource object's type (projects) is not the type that constitute the collection represented by the endpoint (project)."
}
}
显然,JSONApi
规范没有强制执行拐点规则。如何告诉drf
接受该类型的复数?
有一个配置参数:
JSON_API_PLURALIZE_RELATION_TYPE = True
您还可以显式设置资源名称:
class CategoryViewSet(viewsets.ModelViewSet):
resource_name = 'categories'
...