Is it feasible to pass in a dict as an argument to the objects.create
method ?
soDict = {
'customer': data['customer_id'],
'name': data['name'],
}
so = ServiceOrder.objects.create(**soDict)
Is it feasible to pass in a dict as an argument to the objects.create
method ?
soDict = {
'customer': data['customer_id'],
'name': data['name'],
}
so = ServiceOrder.objects.create(**soDict)
Instead of so = ServiceOrder.objects.create(**soDict)
do something like
so = ServiceOrder(**soDict)
so.save()
Also customer
and name
should be fields in your ServiceOrder model.
This works. To be more pedantic, the code in the OP is not passing a dict. It’s unpacking the dictionary as key word arguments (kwargs) to the create method.