Reputation: 2048
I have to have this in my model:
content: (Dictonary)
recipient: (Dictionary)
type: (Facebook, Address or Email)
name: (name or email)
id: (id)
textfields: (Array)
title: (title)
text: (text)
size: (size)
I saw this post and this one, but I can't do it. For me is actually the first time that someone tells me that he needs exactly that structure in the model. I have never seem something like that before. But I'm also new :) so, maybe it's just that I don't know how to do it.
Maybe someone here with more experience than me can help me. I don't have any idea.
EDIT
I mean, I don't have to have it so in the model, but I need to accept POST, DELETE, PUT requests with that structure as well return GET request with that structure.
Upvotes: 0
Views: 633
Reputation: 1344
Dictionaries in python are done like this:
content = {}
type = {'Faceboook': '', 'Address': '', 'Email': ''}
recipient = {'type': type, 'name': '', id: ''}
textfields = {'title': '', 'text':'', 'size':''}
content = {'recipient': recipient, 'textfields': textfields}
> {'textfields': {'text': '', 'size': '', 'title': ''}, 'recipient': {: '', 'type': {'Faceboook': '', 'Email': '', 'Address': ''}, 'name': ''}}
Then you can just store this on a JSONFIELD.
Upvotes: 1