was watching here:
https://youtu.be/F5mRW0jo-U4?t=9267
he proceeds to write the call:
Product.objects.create(**my_form.cleaned_data)
Can someone explain what is the difference between
Product.objects.create(my_form.cleaned_data)
and
Product.objects.create(**my_form.cleaned_data)
Assuming that my_form.cleaned_data is a dict, or some other kind of mapping, then create(**my_form.cleaned_data) will pass all the dict's entries as keyword arguments. So:
def my_fun(a=None, b=None):
    print(a)
    print(b)
my_dict = {'a':1, 'b':2}
my_fun(**my_dict)
would print:
1
2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With