django-conduit icon indicating copy to clipboard operation
django-conduit copied to clipboard

Allow submitting empty data for related fields that are not required

Open blturner opened this issue 10 years ago • 1 comments

If you have a related field that is not required and you don't submit that field in your data, you get a KeyError when Conduit tries to save the related object.

A request to a Conduit endpoint with an empty object for a FK creates an object with empty attributes and adds a resource_uri attribute that points to the list endpoint for the resource:

{
    'id': 1,
    'name': '',
    'resource_uri': '/api/v1/bar/'
}

This change prevents creating a FK if no data is submitted in the request. If you omit data for a non-required FK field in your request data, then the response will return an empty object in the response:

{
    ...
   'bar': {},
   ...
}

blturner avatar Feb 15 '15 23:02 blturner

Currently working on a complete fix for this. Taking me a while to get back into the problem.

akoumjian avatar Apr 13 '15 15:04 akoumjian