Skip to content

Commit

Permalink
Save the resource after processing relationships
Browse files Browse the repository at this point in the history
- Prevents issues saving one-to-many relationships
  • Loading branch information
ddobson committed Aug 29, 2019
1 parent 4536c78 commit 429c5da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drf_jsonapi/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ def partial_update(self, request, *args, **kwargs):
if not serializer.is_valid():
return self.error_response(Error.parse_validation_errors(serializer.errors))

resource = serializer.save()

# Check for relationships and process them
if "relationships" in request.data["data"]:
self.process_relationships(
request.data["data"]["relationships"], resource, request
)

serializer.save()

self.document.instance.data = serializer.data

return Response(self.document.data)
Expand Down

0 comments on commit 429c5da

Please sign in to comment.