model_bakery
model_bakery copied to clipboard
`make()` with `_bulk_create=True` does not create M2M-entries that are specified using the reverse/related name.
When using baker.make with _bulk_create=True, it will silently ignore arguments that should be used to fill many-to-many fields if the arguments use the reverve/related name.
Follow up to #298, where the same issue was fixed when using the forward name of a m2m relationship.
To Reproduce with
class House(models.Model):
pass
class HouseDetail(models.Model):
houses = models.ManyToManyField(House, blank=True)
this snippet fails at the assertion:
detail = baker.make(HouseDetail)
houses = baker.make(House, housedetail_set=[detail], _quantity=20, _bulk_create=True)
assert houses[0].housedetail_set.count() == 1
Expected behavior
For each house instance in houses, the housedetail_set should contain the detail, and thus have count() == 1. This also happens when _bulk_create=False is used.
Versions
- Python: [3.10.6]
- Django [4.1.6]
- Model Bakery [1.9.0]