Hi!
I have to deal with API with encapsulated data, like this:
{
"action":"update",
"issue":{
"id":123,
"Key":"KEY-234",
"fields": {
"creator": "bill",
"summary":"The issue summary",
"category":"cool"},
"user":"bob",
"timestamp": 3555455
}
I need to take some fields from `issue` and put the data to some flat model
like:
class Issue(models.Model):
key = models.CharField(...)
summary = models.CharField(...)
category = models.CharField(...)
But here field `key` and field `summary` are located in different json
objects. How can I extract summary during parsing?
How to write a Serializer?
I've tried to make something using `.to_internal_value()` and
`.representation()` but it looks ugly.
Also it doesn't work, because it tries to find `summary` field during
validation and fails.
Have I to write down my own Field class which will be capable of some
specific parsing like looking into nested objects.
How to make a representation for this field if I home some of them in one
serializer? I will have to merge output into one json object.
Thank you.
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.