Skip to main content

jessilver_django_seed

A library to facilitate the creation of fake data (seeds) in Django projects, with custom management commands, modularization, selective seeder execution, and easy integration.

Installation

Install from PyPI:

pip install jessilver_django_seed

Requirements

  • Python 3.7+
  • Django >= 3.2

Configuration

  1. Add 'jessilver_django_seed' to your INSTALLED_APPS.
  2. In your settings.py, define:
    SEEDER_APPS = [
        'your_app_name',
        # ...other apps
    ]
    
    Each app directory should contain a seeders/ folder with your seeder files.

Seeder Structure

Create Python files in the seeders/ folder of your app. Example:

# myapp/seeders/UserSeeder.py
from jessilver_django_seed.seeders.BaseSeeder import BaseSeeder
from myapp.models import User

class UserSeeder(BaseSeeder):
    @property
    def seeder_name(self):
        return "UserSeeder"
    def seed(self):
        for i in range(10):
            User.objects.create(username=f'user{i}')
        self.succes("10 users created!")

Seed Command

Run all seeders:

python manage.py seed

Selective Execution

Run only specific seeders:

python manage.py seed --only UserSeeder,ProductSeeder

Seeder Creation via CLI

You can create a new seeder file automatically using the management command:

python manage.py seed --create UserSeeder --app myapp
  • This will create a file myapp/seeders/UserSeeder.py with a template class if it does not already exist.
  • If the app is not listed in SEEDER_APPS in your settings.py, it will be added automatically.
  • The command validates the seeder class name and ensures no duplicates.

How it works

  • The library looks for all apps listed in SEEDER_APPS.
  • For each app, it dynamically loads all Python files in the seeders/ folder.
  • It searches for classes ending with Seeder (exemple UserSeeder).

Seed Command

  • Argument --only: Runs only the seeders whose class names are provided.
  • Interactive confirmation before execution.
  • Status messages and summary at the end.

Seeder Execution Order

Seeders are loaded and executed in alphabetical order based on their filename. You can control the execution order by naming your seeder files with numeric or alphabetical prefixes, e.g.:

01_UserSeeder.py
02_ProductSeeder.py

This ensures that seeders run in the desired sequence.

Compatibility

All file and directory operations use Python's os.path.join and standard library functions, ensuring compatibility across Linux, Windows, and MacOS. No hardcoded path separators are used.

Examples

Product Seeder

# myapp/seeders/ProductSeeder.py
from jessilver_django_seed.seeders.BaseSeeder import BaseSeeder
from myapp.models import Product

class ProductSeeder(BaseSeeder):
    @property
    def seeder_name(self):
        return "ProductSeeder"
    def seed(self):
        for i in range(5):
            Product.objects.create(name=f'Product {i}')
        self.succes("5 products created!")

Running only the UserSeeder

python manage.py seed --only UserSeeder

Contributing

Pull requests are welcome! Open issues for suggestions or problems.

License

MIT

Metadata

Release files for jessilver-django-seed 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jessilver-django-seed 2.0.1
File Size Uploaded Provenance Actions
jessilver_django_seed-2.0.1.tar.gz 16.2 kB Without provenance Details for jessilver_django_seed-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jessilver-django-seed 2.0.1
File Interpreter ABI Platform Actions
jessilver_django_seed-2.0.1-py3-none-any.whl Python 3 none any Details for jessilver_django_seed-2.0.1-py3-none-any.whl

Total release size: 33.3 kB

Release files / jessilver_django_seed-2.0.1.tar.gz

Download URL jessilver_django_seed-2.0.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5150d9dbf68743a89333da1e2a1a9847135211cc7207a9d6496490fa7303e0f3
BLAKE2b-256 checksum
How to use checksums
7375f3ac838b55c3d04e0bb65277a47064b0202cf2fe98a027692aacf97f807e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / jessilver_django_seed-2.0.1-py3-none-any.whl

Download URL jessilver_django_seed-2.0.1-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8199d0d6e153e007d8cbfdca45220329ddbfe5c2bb1d39f8ab23014f7d7a26c0
BLAKE2b-256 checksum
How to use checksums
d5439aa6f270880a46c0b7f3d9323b97af41fe038ec2f4f64f280ef4ddde485d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for jessilver-django-seed 2.0.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page