I am working on an application using Django and MongoDB (as a model). I am trying to initialize (manually) a model object (in order to send it further to another server) using the data received from the form. The model is as follows:
class MyModel(DynamicDocument): study_name = StringField(default="first study") individual_name = StringField(default="individual") file_list = ListField(StringField)
In the form, I do the following:
pilot_object = MyModel() pilot_object.individual_name = self.data['individual_name'] pilot_object.study_name = self.data['study_name'] pilot_object.file_list = files_list
where self.data is the data received from the form. Now I want to serialize JSON to this object (pilot_object), as described in the documentation:
data_serialized = serializers.serialize('json', [pilot_object, ])
but I get this error:
MetaDict object does not have attribute 'specific_model'
and serialization failure.
Can anyone help?
Clara source share