Smart object creation facility for Django.
Project description
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.
Installation
pip install model-bakery
Supported Versions
Model Bakery follows the Python and Django release and support cycles. We drop support for Python and Django versions when they reach end-of-life.
Basic usage
# models.py
from django.db import models
class Customer(models.Model):
name = models.CharField(max_length=30)
email = models.EmailField()
age = models.IntegerField()
is_jards_macale_fan = models.BooleanField()
bio = models.TextField()
birthday = models.DateField()
last_shopping = models.DateTimeField()
# test_models.py
from django.test import TestCase
from model_bakery import baker
class TestCustomerModel(TestCase):
def setUp(self):
self.customer = baker.make('shop.Customer')
print(self.customer.__dict__)
"""
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
'age': 3841,
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
'birthday': datetime.date(2019, 12, 3),
'email': 'rpNATNsxoj@example.com',
'is_jards_macale_fan': True,
'id': 1,
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'}
"""
Documentation
For more detailed information, check out the full documentation.
Contributing
As an open-source project, Model Bakery welcomes contributions of many forms:
- Code patches
- Documentation improvements
- Bug reports
Take a look at our contribution guidelines for instructions on how to set up your local environment.
Maintainers
Creator
License
Model Bakery is licensed under Apache License 2.0. See the LICENSE file for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file model_bakery-1.23.2.tar.gz.
File metadata
- Download URL: model_bakery-1.23.2.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42d249903bcdb96875d289b4733c22c8e7b46c3e59604e0538aabe8a3a743fad
|
|
| MD5 |
5d86c78c9d4a090e0c6e6135f073407b
|
|
| BLAKE2b-256 |
901c03217ba882a814e431729ee91f634d747502bc55c8095a49d4f37d68b171
|
Provenance
The following attestation bundles were made for model_bakery-1.23.2.tar.gz:
Publisher:
release.yml on model-bakers/model_bakery
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_bakery-1.23.2.tar.gz -
Subject digest:
42d249903bcdb96875d289b4733c22c8e7b46c3e59604e0538aabe8a3a743fad - Sigstore transparency entry: 843960053
- Sigstore integration time:
-
Permalink:
model-bakers/model_bakery@dd464180537613055bef6d0568c5d60c4406d9f6 -
Branch / Tag:
refs/tags/1.23.2 - Owner: https://github.com/model-bakers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dd464180537613055bef6d0568c5d60c4406d9f6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file model_bakery-1.23.2-py3-none-any.whl.
File metadata
- Download URL: model_bakery-1.23.2-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f1067df0879ea5f0f158aaa7a8b26fd9a6c62cc1f1f08ea288a35023b9f9b1
|
|
| MD5 |
8431b63227a3bfacd944d76ec5e1f91a
|
|
| BLAKE2b-256 |
6ea7616e30ffaff51581003b2d36705f625b0bd14cac2a92a779c22476bea572
|
Provenance
The following attestation bundles were made for model_bakery-1.23.2-py3-none-any.whl:
Publisher:
release.yml on model-bakers/model_bakery
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_bakery-1.23.2-py3-none-any.whl -
Subject digest:
31f1067df0879ea5f0f158aaa7a8b26fd9a6c62cc1f1f08ea288a35023b9f9b1 - Sigstore transparency entry: 843960056
- Sigstore integration time:
-
Permalink:
model-bakers/model_bakery@dd464180537613055bef6d0568c5d60c4406d9f6 -
Branch / Tag:
refs/tags/1.23.2 - Owner: https://github.com/model-bakers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dd464180537613055bef6d0568c5d60c4406d9f6 -
Trigger Event:
release
-
Statement type: