Skip to main content

Smart object creation facility for Django.

Project description

Model Bakery: Smart fixtures for better tests

Build Coverage Latest PyPI version Documentation Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_bakery-1.23.4.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

model_bakery-1.23.4-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file model_bakery-1.23.4.tar.gz.

File metadata

  • Download URL: model_bakery-1.23.4.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for model_bakery-1.23.4.tar.gz
Algorithm Hash digest
SHA256 0cd8e958e229734bd41feffdcb513a0f079c79c9ddb2e0aad11ed2c23f6d43d5
MD5 f7e89252e9841e8e5a3bd28e93674a59
BLAKE2b-256 4151d3cfd4ab5c1cb9f889c604dc96cc0f1d7a52972ee28fe7a44a9dd705521a

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_bakery-1.23.4.tar.gz:

Publisher: release.yml on model-bakers/model_bakery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file model_bakery-1.23.4-py3-none-any.whl.

File metadata

  • Download URL: model_bakery-1.23.4-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for model_bakery-1.23.4-py3-none-any.whl
Algorithm Hash digest
SHA256 65bfa0405d3ea60aca8c21e7e184c6617d6c8d32d0493cc75232a4476f471514
MD5 3cb6f02aeeebd6e8bb02656f4ab8ba3d
BLAKE2b-256 958855c8e0a873e7a0f8e0d6c5ca236512cc37555632be178e7ba72bfbe0a619

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_bakery-1.23.4-py3-none-any.whl:

Publisher: release.yml on model-bakers/model_bakery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page