I want to set the values of the fields of a set of models in a loop.
I need to do that because I have data in xml format (one xml file for each record, approx 500,000 file alltogether) that I need to import into a database.
I can retreive the models of my app using
app_models = apps.get_app_config('ctmatcher').get_models()
I can retrieve the fields of each model by using
But how can I set the content of individual fields? If you would use the explict name of the model you would do
address_object=Address.objects.create( city=address_info['city'], state=address_info['state'], zip=address_info['zip'], country=address_info['country'], facility_id=facility_id )
But how can I generate the address_object, if I only have the model object and the field objects in an immutable list ?