class Person(models.Model):
user = models.OneToOneField("auth.User", on_delete=models.CASCADE, blank=True, null=True)
Now I want to make a recipe for a user that has a person to use in tests:
user = Recipe(User)
person = Recipe(Person)
user_with_person = user.extend(person=foreign_key(person))
when I check test_user = user_with_person.make() it has a test_user.person but when I check the database like this: User.objects.get(id=test_user.id).person it doesn't exist. I can create a person_with_user just fine. Is it not possible to define a reverse relation like this? I've made a small django project to showcase the issue: https://github.com/AlmerCarbonEquity/model-bakery-one-to-one
Expected behavior
I would expect User.objects.get(id=test_user.id).person to exist after test_user = user_with_person.make()
I have the following model:
Now I want to make a recipe for a user that has a person to use in tests:
when I check
test_user = user_with_person.make()
it has atest_user.person
but when I check the database like this:User.objects.get(id=test_user.id).person
it doesn't exist. I can create aperson_with_user
just fine. Is it not possible to define a reverse relation like this? I've made a small django project to showcase the issue: https://github.com/AlmerCarbonEquity/model-bakery-one-to-oneExpected behavior I would expect
User.objects.get(id=test_user.id).person
to exist aftertest_user = user_with_person.make()
Versions