I am sending json data from an angular app to a django view/serializer and need to serialize both arrays at the same time in order to create a user successfully. I tried some ridiculous way of separating the data in the view and doing the two serializations separately, but I realized that it is really messy and would become problematic if errors occurred during the second part.
Basically:
{"email": "foo@foo.com",
"password": "barbar",
"first_name":"baz",
"last_name":"buzz",
"profile":
{"cdata":"1"
"other":"0"
"sex":"m"}
"message": "I don't know what comes after buzz in foo bar baz buzz etc."
}
Should I separate the arrays in the view? If so, how could I tell the serializers which separated array of data they should take?
(This profile data is saved as a oneToOne field with the user model)
If anyone can show me a succinct way of handling this, I would be very grateful.
Please let me know if you can help or if u need more info. I appreciate your time. Thanks.