# Model Bakery: Smart fixtures for better tests

Model Bakery offers you a smart way to create fixtures for testing in Django.

With a simple and powerful API, you can create many objects with a single line of code.

Model Bakery is a rename of the legacy model_mommy’s project. This change was made to avoid reinforcing gender stereotypes in technology. You can read more about this subject here.

Documentation: https://model-bakery.readthedocs.io

Source code: https://github.com/model-bakers/model_bakery/

## Key Features

- Automatically generates test data for Django models

- Provides sensible defaults for all field types

- Supports custom field overrides and “recipes” for reusable patterns

- Handles related models and complex relationships

- Works with currently maintained versions of Python and Django

## Installation

    $ pip install model-bakery

## Contributing to Model Bakery

As an open-source project, Model Bakery welcomes contributions of many forms:

- Code patches

- Documentation improvements

- Bug reports

Take a look at our GitHub repo for instructions on how to set up your local environment.

## Support

Feel free to open an issue for support, development ideas, or questions!

## License

Model Bakery is licensed under the MIT License. See the LICENSE file for more information.

## Contents

- Basic Usage
  - Model Relationships
  - M2M Relationships
  - Explicit M2M Relationships
  - Explicit values for fields
  - Creating Files
  - Refreshing Instances After Creation
  - Non persistent objects
  - More than one instance
  - Multi-database support
- Recipes
  - Recipes with foreign keys
  - Recipes with callables
  - Recipes with iterators
  - Sequences in recipes
  - Overriding recipe definitions
  - Recipe inheritance
- How Model Bakery behaves?
  - When shouldn’t you let Baker generate things for you?
  - Currently supported fields
  - Custom fields
  - Customizing Baker
  - Save method custom parameters
- Test Runners
  - Django
  - pytest
- Migrating from Model Mommy