I’ve ran into an error during work where I was sending a mock instance to an object creation and the error was difficult to identify/understand! I noticed there is an issue created for this in the tracker: #25493 (Model instances created with unittest.mock can raise confusing errors) – Django. But not sure what would be a proper solution! Any idea/suggestion? Just trying to get a brainstorming session here! Thank you so much!
ValueError: Failed to insert expression "<MagicMock name='create().id.resolve_expression()' id='139633074508184'>" on fundraising.Payment.stripe_charge_id. F() expressions can only be used to update, not to insert.
It seems that you are trying to use the F() expression which is mostly used to update existing models’ fields. Kindly modify that or provide more information about the code that is creating this issue.