In order to build the links in the returned validation error I moved the validation to the validate method of the serializer. Seeing as we don't require an inchikey it is not supplied in initial_data until the to_internal_value method is run.
As for the error, IDK if all of the keys are really required to keep in the output, I had just kept it as close to how it was originally and added the links, but if you look closer in the tests at the serialized.errors you will see that it is not really a pretty object, but delivers what is needed.
In order to build the links in the returned validation error I moved the validation to the
validate
method of the serializer. Seeing as we don't require aninchikey
it is not supplied ininitial_data
until theto_internal_value
method is run.As for the error, IDK if all of the keys are really required to keep in the output, I had just kept it as close to how it was originally and added the
links
, but if you look closer in the tests at theserialized.errors
you will see that it is not really a pretty object, but delivers what is needed.