model-bakers / model_bakery

Object factory for Django
https://model-bakery.readthedocs.io/en/latest/
Other
845 stars 85 forks source link

Django 5 db_default field parameter ignored when creating recipies #479

Closed majorgilles closed 2 months ago

majorgilles commented 5 months ago

Describe the issue Model bakery seems to ignore the new django 5.+ field setting "db_default".

To Reproduce

  1. Original version of a field:

        null=False, default=20, help_text="In percentage (0-100)"
    )
  2. Switching to db_default:

        null=False, db_default=20, help_text="In percentage (0-100)"
    )
  3. Baked model using this field assigns a random positive integer value

  4. I have to explicitly set the value in the Recipe for it to work

Expected behavior db_default parameter should be used as default in the recipe just as former default parameter was used instead of a random int

Versions