Follow-Up to #385, which was fixed in #486. When specifying values for a M2M field that has a reverse_name, baker currently tries to create an instance of the through-model using the related name when _bulk_create=True is passed.
Add this test case to TestCreateM2MWhenBulkCreate. Note that it is very similar to test_create, just the model used is switched from Classroom to Store, since Store.customers specifies a related_name.
___TestCreateM2MWhenBulkCreate.test_create_with_field_with_related_name ___
tests/test_baker.py:1090: in test_create_with_field_with_related_name
baker.make(
model_bakery/baker.py:131: in make
return bulk_create(baker, _quantity, _save_kwargs=_save_kwargs, **attrs)
model_bakery/baker.py:857: in bulk_create
[
model_bakery/baker.py:858: in <listcomp>
through_model(
../../.local/lib/python3.10/site-packages/django/db/models/base.py:567: in __init__
raise TypeError(
E TypeError: Store_customers() got unexpected keyword arguments: 'favorite_stores'
Versions
Python: 3.10.12
Django: 4.2
Model Bakery 1.19.1 (tested at d758c7ae5a5f4a41588f96fc2562d1ae91d3e062)
Follow-Up to #385, which was fixed in #486. When specifying values for a M2M field that has a
reverse_name
, baker currently tries to create an instance of the through-model using the related name when_bulk_create=True
is passed.Add this test case to
TestCreateM2MWhenBulkCreate
. Note that it is very similar totest_create
, just the model used is switched fromClassroom
toStore
, sinceStore.customers
specifies arelated_name
.The test fails with this error:
Versions