Can a dictionary be passed to django models on create?

Viewed 77054

Is it possible to do something similar to this with a list, dictionary or something else?

data_dict = {
    'title' : 'awesome title',
    'body' : 'great body of text',
}

Model.objects.create(data_dict)

Even better if I can extend it:

Model.objects.create(data_dict, extra='hello', extra2='world')
3 Answers

For any model DummyModel you can use DummyModel.objects.create(**data_dict). Does not require save after the create.

Related