EmberData 和 Django REST 框架之间的类型转换冲突

Conflict in type inflection between EmberData and Django REST framework

EmberDataPOSTing:

{
  "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 规范 does not 强制执行词形变化规则。我如何告诉 drf 接受类型的复数形式?

有个config parameter:

JSON_API_PLURALIZE_RELATION_TYPE = True

您也可以显式设置资源名称:

class CategoryViewSet(viewsets.ModelViewSet):
    resource_name = 'categories'
    ...