I can't figure out how to serialize cleaned_data
of some form. The problem probably is, that this cleaned_data
contains model objects
. I didn't find anything touching this problem so I'm asking here.
Exception Value:
'dict' object has no attribute '_meta'
Is there some simple way or Django built-in function?
My cleaned_data:
{'notes': u'dsads', 'language_from': <Language: Slovak>, 'file': None, 'short_description': u'dsadsad', 'text_to_translate': u'dsads', 'delivery_date': datetime.date(1930, 1, 1)}
This is a formset
cleaned_data:
[{'language': <Language: Magyar>, 'level': <Level: Standard level>},
{'language': <Language: Russian>, 'level': <Level: Standard level>}, {}, {}, {}]
serializer.serialize(cleaned_data)
does not works because there are models
inside the cleaned_data
.
Only way I probably figured out is to change all objects to it's primary keys and after deserialize get them from the database.
I want to serialize cleaned_data because I sending them to another view.
serialize.serialize
applies to querysets or object instances, not to dicts, hence the error message.