[Fixed]-Dictionary in a model of django rest framework

1👍

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.

Leave a comment