All notable changes to model_bakery will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- Speed up
Baker.get_fields()by returning_meta.fields + _meta.many_to_manydirectly instead of filtering_meta.get_fields().
- Fix AttributeError when processing models with reverse ForeignKey relations (
ManyToOneRel) (#575) - Fix
_bulk_createnot setting M2M fields on FK-related objects (#583) - [dev] Fix type annotations (#584)
- [dev] Fix remaining ty type errors in baker.py and generators.py (#589)
- [dev] Replace mypy with ty as the primary type checker with stricter type checks
- [dev] Fix ty 0.0.17 compatibility: update rule config, fix generic TypeVar bound, pin minimum version
- Allow overriding
AutoFieldvalues via iterators with_quantityand avoid hangs (#577)
- Fix
_bulk_create=Trueto use bulk_create even without_quantity(#462)
- Fix
_bulk_createfor ManyToManyField using customthroughmodels (#477) - [dev] Clean up stale TODO and fix signal handler leak in m2m test
- [dev] Drop JSONField workarounds from tests
- Fix
related()with FK relations creating duplicate parent entities (#397) - [dev] CI: use uv for faster dependency installation and caching
- [dev] Fix missing psycopg dependency in tox no-contenttypes environment
- [dev] Fix
USE_CONTENTTYPES=Falsenot actually disabling contenttypes in tests
- Drop EOL Django 5.0 and 5.1 support
- [dev] PyPI releases now use trusted publishing
- [dev] Switch build backend from hatchling to uv_build
- Add explicit field-specific generators for
AutoField,BigAutoField, andSmallAutoField(#61) - Add dedicated generators for each integer field type that use Django's actual field ranges (#61)
- Deprecate
gen_integer()in favor of field-specific generators that respect Django's field ranges (#61) prepare()withGenericForeignKeyno longer accesses the database;content_objectattribute is unavailable in this mode- Add type hints to
seq()'sincrement_byargument - docs: Update
seq()import in basic usage
- Drop mentions of model_mommy from the project. The old migration script is available in the GitHub gist.
- Add Python 3.14 support
- Add Django 6.0 support
- The creation of generic foreign key fields now respects their
for_concrete_modelconfiguration - Refactor
gen_float()to useuniform()with configurablemin_float/max_floatbounds instead ofrandom() * gen_integer()which produced skewed distribution - Refactor
gen_interval()to usemin_interval/max_intervalinstead ofoffsetparameter which never worked as intended due to hugeMAX_INTrange - Fix
gen_date_range()andgen_datetime_range()to prevent empty ranges by enforcing a minimum interval of 1 day - Use
baker_random.randint()directly ingen_pg_numbers_range()instead ofgen_integer() - The
gen_from_choicesgenerator now ignoresNoneor""values in choices when the field doesn't allow null or blank values - [dev] Various improvements to CI Python/Django matrices
- Drop fallbacks made for Django < 4.2
- Drop Python 3.8 and 3.9 support (reached end of life)
- Add Django 5.2 support
- Improve documentation
- Fix regression introduced in 1.20.3 that prevented using
auto_nowandauto_now_addfields with seq or callable.
- Fix support of
auto_nowandauto_now_addfields in combination with_fill_optional - Isolate Recipe defaults to prevent modification via instances
- Fix setting GFK parameter by a callable
- Fix regression forbidding using Proxy models as GFK
- docs: Add missing doc on
_refresh_after_createoption
- Fix
Recipe.preparewithout_quantity(on one-to-one relation)
- Remove deprecation warning of
datetime.datetime.utcfromtimestamp.
- Support to Field
db_defaultvalue - Support to Python 3.13
- Reset
content_typeandobject_idfields when the content object isNone
- Allow
Nonevalue for generic foreign keys within iterators - Make
TextFieldgenerator respectmax_length - Deprecate
model_bakery.random_gen.gen_textin favor ofmodel_bakery.random_gen.gen_string
- Do not handle GFK fields when the object is None
- docs: Add Django settings example for custom field generators
- Align GFK and content type fields generation
- Allow
prepare()to be used with GFK
- Handle bulk creation when using reverse related name
- Add Django 5.1 support
- Fix support of
GenericForeignKeyfields in combination with_fill_optional
- Fix
make_recipeto work with_quantity(#28)
- Replace expensive
count()with cheapexists()
- Add Django 5.0 support
- Allow baking without
contenttypesframework
- Drop Django 3.2 and 4.1 support (reached end of life)
- Add support to
auto_nowandauto_now_addfields.
- Remove unnecessary casting to string methods
random_gen.gen_slugandrandom_gen.gen_string - [doc] Update installation command
- [dev] Test coverage report
- Improved performance of
Baker.get_fields() - [dev] Cleanup Sphinx documentation config
- [dev] Update
pre-commitconfig - [dev] CI: remove hard requirement on linters for tests to run
- Add Python 3.12 support
- Revert erroneous optimisation of related logic (fix #439)
- [dev] Bring tox back
- forward "_create_files" flag to child generators for relational fields
- Small improvements to
recipe.py::_mapping - Improvements to
baker.py::bulk_create - [dev] Replaced
pycodestyle,pydocstyle,flake8andisortwithruff - [dev] Drop tox in favor of using GitHub Actions matrix
- Drop
baker.py::is_iterator - Drop Python 3.7 support (reached end of life)
- Add support for global seeding to baker random generation
- Add support for CharField with max_length=None
- Fix utils.seq with start=0
- Add psycopg3 support for Django 4.2
- Enforce Python 3.7 as a minimum version in project metadata
- dropped support for
FloatRangeFieldas it was removed in Django 3.1 - [dev] Temporary drop Django 4.2 to package classifiers (waiting for build backend support)
- [dev] Test Python 3.11 with Django 4.2
- [dev] Add Django 4.2 to package classifiers
- [dev] Fix GitHub Action for publishing to PyPI
- Django 4.2 support
- [dev] Switch to Python 3.11 release in CI
- [dev] Unify and simplify tox config with tox-py
- [dev]
pre-commit autoupdate && pre-commit run --all-files - [dev] Run
pyupgradewith Python 3.7 as a base - [dev] PEP 621: Migrate from setup.py and setup.cfg to pyproject.toml
- [dev] Convert
formatand some string interpolations tofstring
- Fixed a bug with
seqbeing passed a tz-aware start value PR #353 - Create m2m when using
_bulk_create=TruePR #354 - [dev] Use official postgis docker image in CI PR #355
- Improve
Baker.get_fields()to subtract lists instead of extra set cast PR #352
- Remove warning for future Django deprecation PR #339
- Fixed a bug with overwritten
_save_kwargsand other custom arguments PR #330
- Python 3.11 support PR #327
- Django 4.1 support PR #327
- Added documentation for callables, iterables, sequences PR #309
- [dev] Replace changelog reminder action with a custom solution that can ignore Dependabot PRs PR #328
- Extend type hints in
model_bakery.recipemodule, makeRecipeclass generic PR #292 - Explicitly add _fill_optional parameters to baker.make and baker.prepare to aid IDE autocomplete function. PR #264
- Fixed errors with reverse M2M relationships PR #299
- Fixed errors with reverse M2O relationships PR #300
- Improve exception message for unknown field types PR #301
- Fixed random generation of ContentType values when there is no database access #290
- Added postgis version to test settings
- Add support for Python 3.10 PR #244
- Support for Django 4.0 PR #236
- Validate
increment_byparameter ofseqhelper whenvalueis an instance ofdatetimePR #247 - Fix a simple typo in
bulk_createdisclaimer in docs PR #245 - Allow relation
_idfields to use sequences PR #253 - Fix bulk_create not working with multi-database setup PR #252
- Conditionally support NullBooleanField, it's under deprecation and will be removed in Django 4.0 PR #250
- Fix Django max version pin in requirements file PR #251
- Improve type hinting to return the correct type depending on
_quantityusage PR #261
- Drop official Django 3.1 support. Django 2.2 is still supported, and 3.1 will likely keep working, but it’s not tested PR #236
_bulk_createflag is not populating related objects as well PR #206- Add support for iterators on GFK fields when using _quantity param PR #207
- Add support for iterators on many-to-many fields PR#237
- Fix typos in Recipes documentation page PR #212
- Add
venvto ignored folders offlake8andpydocstylePR#214 - Run
flake8after code modifications when linting PR#214 - Add typing for
baker.makeandbaker.preparePR#213
- Fixed a bug (introduced in 1.2.1) that was breaking imports of recipes from non-installed-app modules PR #201
- Dependencies updates
- [dev] Add explanations to imports in
generators.pyto match with current supported Django versions PR #179
- Fix
requirements.txtto cover Django 3.2 (everything from 2.2 till 4.0) PR #182
- Add Django 3.2 LTS support PR #176
- Add new
_bulk_createparameter tomakefor using Django managerbulk_createwith_quantityPR #134 - Add the functionality to import Django models using the
app_name.ModelNameconvention inimport_from_strPR #140 - Add the functionality to import recipes using
app_name.recipe_namePR #140 - Add new
one_to_oneparameter toforeign_keyto allow usage of_quantityfor recipes based on models with OneToOne fields PR #169 - [docs] Improved documentation on Recipe's import string PR #175
- [dev] Add a unit test for
utils.seqPR #143 - [dev] Run CI against
mainDjango branch to cover possible upcoming changes/deprecations PR #159 - [dev] Add GH Action for package releasing PR #168
- Fixed a bug (introduced in 1.2.1) that was breaking creation of model instances with related model fields PR #164
- Type hinting fixed for Recipe "_model" parameter PR #124
- Dependencies updates from dependabot PRs #170 - #171 - #172 - #173 - #174
- [dev] Modify
setup.pyto not import the whole module for package data, but get it from__about__.pyPR #142 - [dev] Add Dependabot config file PR #146
- [dev] Update Dependabot config file to support GH Actions and auto-rebase PR #160
model_bakery.timezone.nowfallback (usedjango.utils.timezone.nowinstead) PR #141model_bakery.timezone.smart_datetimefunction (directly usemodel_bakery.timezone.tz_awareinstead) PR #147- Remove all signs of Django 1.11 (as we dropped it in 1.2.1) PR #157
- Drop unsupported Django 3.0 from CI (https://www.djangoproject.com/download/#unsupported-versions) PR #176
- Add ability to pass
strvalues toforeign_keyfor recipes from other modules PR #120 - Add new parameter
_usingto support multi database Django applications PR #126 - [dev] Add instructions and script for running
postgresandpostgistests. PR #118
- [dev] Drop Python 3.5 support as it is retired (https://www.python.org/downloads/release/python-3510/) PR #119
- [dev] Remove support for Django<2.2 (more about Django supported versions) PR #126
- Support to django 3.1
JSONFieldPR #85 and PR #106 - Added type annotations PR #100
- Support for Python 3.9 PR #113
- [dev] Changelog reminder (GitHub action)
- Add pytest example
- Support for
prefixinseqvalues (PR #111 fixes Issue #93) - [dev] CI switched to GitHub Actions
- [dev] Freeze dev requirements
- [dev] Add Django 3.1 to test matrix PR #103 and PR #112
- [dev] pre-commit to use local packages (so versions will match)
- [dev] consistent use of pydocstyle
- [dev] Updates to MANIFEST.in
- [dev] Correct field in recipe docs
- [dev] Adjust imports for Django 3.1 compatibility PR #112
- Support to Postgres fields:
DecimalRangeField,FloatRangeField,IntegerRangeField,BigIntegerRangeField,DateRangeField,DateTimeRangeFieldPR #80
- Add isort and fix imports PR #77
- Enable
seqto be imported frombakerPR #76 - Fix PostGIS model registration PR #67
- Django 3.0 and Python 3.8 to CI PR #48
- Improve code comments PR #31
- Switch to tox-travis PR #43
- Add black job PR #42
- README.md instead of rst PR #44
- New
startargument inbaker.seqPR #56 - Fixes bug when registering custom fields generator via
settings.pyPR #58 - The different IntegerField types now will generate values on their min/max range PR #59
- Improvements on the migrations script
- Python script to help developers on migrating from Model Mommy to Model Bakery
- Rename model_mommy code to model_bakery