Django serialization for JSON error: MetaDict object does not have attribute 'specific_model'

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) # this is a list of paths to some files 

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 #file paths (strings) 

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?

+6
source share
2 answers

This is due to the use of the old version of django. Check the difference between 1.3 and 1.4 , concrete_model is only available for version 1.4 and higher.

0
source

If you have meta {Inheritance: True}, then delete it. He is looking for a specific class that I think you don’t need, so there is no need for inheritance to be Truth anyway. It worked for me.

0
source

All Articles