pythondjangoapitastypie

tastypie PUT error unauthorized 401 when edit related fields


so I just try to use tastypie put method to edit objects. let's say my object have this structure:

{
  "id": 38,
  "media": [],
  "name": "tesdr",
  "resource_uri": "/api/v2/group/38/",
  "status": 7,
  "user_name": null,
  "users": []
}

witch media and users are related many to many field. when I edit group and use put without any change in m2m fields every thing works fine. but when I try to put something like this:

{
  "id": 38,
  "media": [
    "/api/v2/media/70/"
  ],
  "name": "testgpat",
  "resource_uri": "/api/v2/group/40/",
  "status": 6,
  "user_name": null,
  "users": []
}

tastypie return an 401 http error. so what is the solution? any idea?


Solution

  • ok! I just solved the problem. have to define a many to many field in both resources which wants to set relation. thanks all! :D