[Answered ]-Field id expected a number but got <Cart: John's cart>

1👍

At first, the update_or_create() method returns a tuple containing the object and a boolean value indicating whether it was created or updated. So, you should unpack the tuple to get the actual Cart instance as:

usercart, created = Cart.objects.update_or_create(user=user, cart_total=total)

Leave a comment