django-fakegen
A Django package for generating smart fake data for your models. It leverages Faker to automatically populate Django models with realistic data, supporting a wide range of field types, including relations.
Features
- Generate fake data for any Django model, including related fields
- Supports bulk generation
- Customizable via field overrides
- CLI integration via Django management command
Installation
pip install django-fakegen
Add django_fakegen to your INSTALLED_APPS if needed (not strictly required for management command usage).
Example:
# settings.py
INSTALLED_APPS = [
# ...
'django_fakegen',
# ...
]
Usage
Command Line
Generate 10 fake instances for a model:
python manage.py fakegen app_label.ModelName
Generate a custom number of instances:
python manage.py fakegen app_label.ModelName --count 50
Programmatic Usage
You can use the registry directly in your code:
from django_fakegen.registry import registry
# Generate a single instance
instance = registry.generate_instance(MyModel)
# Generate multiple instances
instances = registry.bulk_generate('app_label.ModelName', count=20)
Supported Fields
django-fakegen supports the following Django field types:
| Field Type | Generator Behavior |
|---|---|
| CharField | Title-like string, respects max_length |
| TextField | Realistic text, up to 250 chars |
| IntegerField | Random integer (0-100) |
| PositiveIntegerField | Random integer (0-100) |
| FloatField | Random float (5 digits left, 2 right) |
| BooleanField | Random boolean |
| DateTimeField | Random datetime (this year) |
| DateField | Random date (this year) |
| TimeField | Random time |
| EmailField | Random email address |
| ForeignKey | Random related instance |
| OneToOneField | Random related instance |
| ManyToManyField | List of 3 random related instances |
Example
Suppose you have a model:
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
class Book(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
published = models.BooleanField()
author = models.ForeignKey(Author, on_delete=models.CASCADE)
You can generate fake data for Book (and related Author) with:
python manage.py fakegen myapp.Book --count 5
Or programmatically:
from django_fakegen.registry import registry
books = registry.bulk_generate('myapp.Book', count=5)
Extending
You can add your own field generators by subclassing BaseFieldGenerator and adding them to the registry.
Contributing
Contributions are welcome! If you'd like to help improve django-fakegen, please open an issue or submit a pull request on GitHub.
License
MIT
Metadata
Release files for django-fakegen 3.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_fakegen-3.4.4.tar.gz | 10.3 kB | Without provenance | Details for django_fakegen-3.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_fakegen-3.4.4-py3-none-any.whl | Python 3 | none | any | Details for django_fakegen-3.4.4-py3-none-any.whl |
Total release size: 21.7 kB
Release files / django_fakegen-3.4.4.tar.gz
| Download URL | django_fakegen-3.4.4.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9cc2401c842fa75b9fe963ac4ea121412320c7ded272ecace44958296ba9b83
|
|
BLAKE2b-256 checksum How to use checksums |
c03f52ce34ba302f08ce8927f79f3857d7bdb3caf0bb76a77351bd2b39f1f0f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / django_fakegen-3.4.4-py3-none-any.whl
| Download URL | django_fakegen-3.4.4-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fc88c6f42dee5d089ed41fcc2fae5f41b978d05e0b7ddefb3520e16769d8dae
|
|
BLAKE2b-256 checksum How to use checksums |
b152778015e1650d741b87fb155c8be60b2597153ba468712d41400f1cd1aef5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for django-fakegen 3.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.