Answer the question
In order to leave comments, you need to log in
When writing a unit test to save/change a model, how do you get rid of the FK in Django?
I use pytest for unit tests. The situation is such that I want to test, for example, the creation of a new record.
1. I'm trying to create an object through pytest. The problem is that it is necessary to create third-party objects in order to fill in the required FK field (and they also have mandatory FKs, etc.). That's why there is such a complexity
2. I'm trying to create an object through mock. I mock the object and substitute my value, but the problem is that the object is not actually created, and I'm just juggling the data here.
That's why I'm looking for a better solution.
Ps or maybe you can somehow create an object in 1 way, only all FK could not be filled.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question