[Answer]-Djangorestframework: Example of POSTing a nested json object in one single request?

1👍

Update: Wait a minute–are nested writes (I think this is what I am trying to accomplish) supported in DjangoRestFramework?

In the sense of, “Is there a generic view that will auto-magically do it all for me?” — No, not yet.

Your best bet is to extend one of the base classes, e.g. APIView and implement post to loop over the request body, create the required entities and set the relationships. Yes, you have to write the code by hand, but there shouldn’t be too much of it. Remember you can still leverage the validation behaviour of DRF serialisers inside your own code.

Leave a comment