[Answered ]-Reference Django Model Field from iterator in a for loop

1👍

You can "unpack" the dictionary, with:

ModelOne.objects.create(**r)

if r might contain other fields than fieldone and fieldtwo, you will need to filter these out, so:

FIELDS = {'fieldone', 'fieldtwo'}
ModelOne.objects.create(**{k: v for k, v in r.items() if k in FIELDS})

Leave a comment