model-bakers / model-bakers/model_bakery
Can't extend receipt through reverse name of OneToOne field.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1k
- Forks
- 107
- Avg merge
- 13h 27m
- Merged PRs (30d)
- 12
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the relationship shown in models.py using the recipe setup in reciepts.py, focusing on the reverse one-to-one name one_related. Verify the intended behavior by checking whether person.extend(one_related=name) creates the related object and preserves the relationship; the issue provides no test file or implementation entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100