# Model Bakery: Smart fixtures for better tests
[](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)
[](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)
[](https://pypi.python.org/pypi/model_bakery/)
[](https://model-bakery.readthedocs.io/en/latest/?badge=latest)
*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 project](https://pypi.org/project/model_mommy/).
## Install
```bash
pip install model-bakery
```
## Usage and Info
### Basic usage
```python
# models.py
from django.db import models
class Customer(models.Model):
enjoy_jards_macale = models.BooleanField()
name = models.CharField(max_length=30)
email = models.EmailField()
age = models.IntegerField()
bio = models.TextField()
days_since_last_login = models.BigIntegerField()
birthday = models.DateField()
last_shopping = models.DateTimeField()
# test_models.py
from django.test import TestCase
from model_bakery import baker
from pprint import pprint
class TestCustomerModel(TestCase):
def setUp(self):
self.customer = baker.make('shop.Customer')
pprint(self.customer.__dict__)
"""
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
'age': 3841,
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
'birthday': datetime.date(2019, 12, 3),
'enjoy_jards_macale': True,
'id': 1,
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',
'days_since_last_login': 6016}
"""
```
Check out [documentation](<http://model-bakery.readthedocs.org/>) for more complete examples.
## Contributing
Detailed info [here](https://github.com/model-bakers/model_bakery/blob/main/CONTRIBUTING.md).
## Maintainers
- [Bernardo Fontes](https://github.com/berinhard/)
- [Rustem Saiargaliev](https://github.com/amureki/)
- [Tim Klein](https://github.com/timjklein36)
## Creator
- [Vanderson Mota](https://github.com/vandersonmota/)
Raw data
{
"_id": null,
"home_page": null,
"name": "model-bakery",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "django, factory, python, testing",
"author": null,
"author_email": "berin <bernardoxhc@gmail.com>, amureki <amureki@hey.com>",
"download_url": "https://files.pythonhosted.org/packages/05/dc/6d6260fa30c4d041958f71d6790b722e6f2588fbbca0534779b81a83b66d/model_bakery-1.20.4.tar.gz",
"platform": null,
"description": "# Model Bakery: Smart fixtures for better tests\n\n[](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)\n[](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)\n[](https://pypi.python.org/pypi/model_bakery/)\n[](https://model-bakery.readthedocs.io/en/latest/?badge=latest)\n\n*Model Bakery* offers you a smart way to create fixtures for testing in\nDjango.\nWith a simple and powerful API you can create many objects with a single\nline of code.\n\nModel Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).\n\n## Install\n\n```bash\npip install model-bakery\n```\n\n## Usage and Info\n\n### Basic usage\n\n```python\n\n# models.py\n\nfrom django.db import models\n\nclass Customer(models.Model):\n enjoy_jards_macale = models.BooleanField()\n name = models.CharField(max_length=30)\n email = models.EmailField()\n age = models.IntegerField()\n bio = models.TextField()\n days_since_last_login = models.BigIntegerField()\n birthday = models.DateField()\n last_shopping = models.DateTimeField()\n\n# test_models.py\n\nfrom django.test import TestCase\nfrom model_bakery import baker\nfrom pprint import pprint\n\nclass TestCustomerModel(TestCase):\n def setUp(self):\n self.customer = baker.make('shop.Customer')\n pprint(self.customer.__dict__)\n\n\"\"\"\n{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,\n 'age': 3841,\n 'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',\n 'birthday': datetime.date(2019, 12, 3),\n 'enjoy_jards_macale': True,\n 'id': 1,\n 'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),\n 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',\n 'days_since_last_login': 6016}\n\"\"\"\n\n```\n\nCheck out [documentation](<http://model-bakery.readthedocs.org/>) for more complete examples.\n\n## Contributing\n\nDetailed info [here](https://github.com/model-bakers/model_bakery/blob/main/CONTRIBUTING.md).\n\n## Maintainers\n\n - [Bernardo Fontes](https://github.com/berinhard/)\n - [Rustem Saiargaliev](https://github.com/amureki/)\n - [Tim Klein](https://github.com/timjklein36)\n\n## Creator\n\n - [Vanderson Mota](https://github.com/vandersonmota/)\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Smart object creation facility for Django.",
"version": "1.20.4",
"project_urls": {
"Homepage": "https://github.com/model-bakers/model_bakery"
},
"split_keywords": [
"django",
" factory",
" python",
" testing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "81239b30a9c70e1a6df5100ae8c440b98fc1da6a4ce195327a7fba399569a2ec",
"md5": "821021886447026c655ea197a8e377fc",
"sha256": "30ad372604f326a1ba9f949bad9d0f85e6a510db4ef6a0b07be2d6bd7485008b"
},
"downloads": -1,
"filename": "model_bakery-1.20.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "821021886447026c655ea197a8e377fc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 24154,
"upload_time": "2025-02-26T20:10:03",
"upload_time_iso_8601": "2025-02-26T20:10:03.988410Z",
"url": "https://files.pythonhosted.org/packages/81/23/9b30a9c70e1a6df5100ae8c440b98fc1da6a4ce195327a7fba399569a2ec/model_bakery-1.20.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "05dc6d6260fa30c4d041958f71d6790b722e6f2588fbbca0534779b81a83b66d",
"md5": "4b12527ad618b4e04e28439b0ed4b892",
"sha256": "a0c97e8a27329ecad78136f9d8f573ae392e4282326ea5c5f6daed1173013c4e"
},
"downloads": -1,
"filename": "model_bakery-1.20.4.tar.gz",
"has_sig": false,
"md5_digest": "4b12527ad618b4e04e28439b0ed4b892",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 21147,
"upload_time": "2025-02-26T20:10:05",
"upload_time_iso_8601": "2025-02-26T20:10:05.713640Z",
"url": "https://files.pythonhosted.org/packages/05/dc/6d6260fa30c4d041958f71d6790b722e6f2588fbbca0534779b81a83b66d/model_bakery-1.20.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-26 20:10:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "model-bakers",
"github_project": "model_bakery",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "model-bakery"
}