model-bakers/model_bakery

I've still got AttributeError: 'ManyToManyRel' object has no attribute 'has_default'

Johnywhisky opened this issue · 0 comments

Hi there, first of all I'm not a native at ENG so �there may be typos or grammatical errors.

I've used python 3.7 and django 3.2 model_baker 1.13 but I just updated those to lastest version.

After then whenever I run test code I get AttributeError: 'ManyToManyRel' object has no attribute 'has_default'

when I used previous version, I never saw this error.

Is this my fault or some issue still remain??

if my_fault is True:
    promise res = solution()
    return res

Expected behavior

# user.baker_recipe.py
active_user = Recipe(
    "user.User",
    phone_device=True,
    is_active=True,
    is_admin=False,
    is_marketing=True,
    _fill_optional=["email", "phone", "name", "nickname", "headline"],
)

# recipe.baker_recipe.py
recipe = Recipe(
    "recipe.Recipe",
    author=foreign_key(active_user),
    _fill_optional=True,
)

# recipe/test.py
recipe = baker.make_recipe("apps.recipe.recipe", author=user)

last code should return recipe instance but it doesn't work

Actual behavior

File "/Users/johnyoun/.local/share/virtualenvs/my_env/lib/python3.9/site-packages/model_bakery/baker.py", line 641, in generate_value if field.has_default() and field.name not in self.rel_fields: AttributeError: 'ManyToManyRel' object has no attribute 'has_default'

Versions

Python: 3.7->3.9
Django: 3.2->4.0.1
Model Bakery: 1.13->1.14.0