You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
Versions
Python: [3.12.0]
Django [5.0.2]
Model Bakery [1.17.0]
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: