Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't extend receipt through reverse name of OneToOne field. #97

Open
prokoptsev opened this issue Aug 17, 2020 · 1 comment
Open

Can't extend receipt through reverse name of OneToOne field. #97

prokoptsev opened this issue Aug 17, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@prokoptsev
Copy link

This is available for foreign_key fields and reverse many2many fields(related), but I haven't found (maybe badly searched) how to do it for backward one-to-one field access. I mean that:

# models.py
from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=256)

class RelatedNamesModel(models.Model):
    name = models.CharField(max_length=256)
    one_to_one = models.OneToOneField(
        Person, related_name="one_related", on_delete=models.CASCADE
    )

# reciepts.py
from model_bakery.recipe import Recipe
from models import Person, RelatedNamesModel

person = Recipe(Person)
name = Recipe(RelatedNamesModel)
person_with_names = person.extend(one_related=name)  # it's not work

Versions

Python: 3.8.3
Django: 3.0.8
Model Bakery: 1.1.1

@berinhard
Copy link
Member

Thanks for opening this issue @prokoptsev! I'll try to reproduce the error within an unit test and, if it breaks, we can work on top of it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants