Fix Python – TransactionManagementError “You can’t execute queries until the end of the ‘atomic’ block” while using signals, but only during Unit Testing

I am getting TransactionManagementError when trying to save a Django User model instance and in its post_save signal, I’m saving some models that have the user as the foreign key.
The context and error is pretty similar to this question
django TransactionManagementError when using signals
However, in this case, the error occurs only while unit te….