django-data-seeder
This app provides a simple way of seeding data for your data models into your development or test database. This can be achieved through the Admin site, via a management command, or by writing your own scripts that use a seeder object.
It is often necessary to be able to seed large datasets, especially in complex projects, where having pre-loaded data can save time in the development lifecycle. Additionally, by allowing simple data seeding, you can more effectively conduct load tests or test complex edge case scnearios.
Requirements
Django 2.2+
Python 3.6+
Installation
You can install data_seeder using pip
pip install django-data-seeder
Quick Start
Add data_seeder to your INSTALLED_APPS in settings.py
INSTALLED_APPS = [ ... 'data_seeder', ]Seed data with the following command
python manage.py seeddata [options] app.models.Model [app.models.Model2, ...]This will generate a single seed for each model provided.
Advanced Usage of the Management Command
In addition to generating single seeds for models, the seeddata can also create as many seeds as you want
python manage.py seeddata --seeds=N apps.model.Model
This will generate N seeds for apps.model.Model
Another option that you can use is to generate related models. This is used for foreign key references where we need to recursively generate seeds for models. The default behaviour for this is disabled, meaning that a randomly selected existing model will be used for the related model field. We override this by doing the following
python manage.py seeddata --generate-related apps.model.Model
One limitation to this behavior is that the data seeder will not generate a related model if the relation is the model itself. This would cause an infinite recursion.
For more information about the seeddata command, please look at the help page.
python manage.py help seeddata
Using the Django Admin Site
For convenience, you can also use the out-of-the-box Administrator site included with Django to generate your seeds.
To do this, you must register your models with the admin site using the custom ModelAdmin class provided. For example, in admin.py for your app
from django.contrib import admin
from .models import MyModel
from data_seeder.admin import DataGeneratorAdmin
admin.site.register(MyModel, DataGeneratorAdmin)
This will add a button to the model page in the admin site to generate data, which will provide you with the same options available in the management command.
You can also register your models using a decorator instead
from django.contrib import admin
from .models import MyModel
from data_seeder.admin import data_generator_register
@admin.register(MyModel)
@data_generator_register
class MyModelAdmin(admin.ModelAdmin):
pass
Contribute
You can find the latest development version on GitHub. Feel free to fork it, file bugs, or contribute.
Metadata
Release files for django-data-seeder 0.2.0
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-data-seeder-0.2.0.tar.gz | 12.0 kB | Without provenance | Details for django-data-seeder-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_data_seeder-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for django_data_seeder-0.2.0-py3-none-any.whl |
Total release size: 28.4 kB
Release files / django-data-seeder-0.2.0.tar.gz
| Download URL | django-data-seeder-0.2.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb5e7bfa2ec290f20ed6dbae1d8367c48e607bc729e308e54601f1cc69095fbc
|
|
BLAKE2b-256 checksum How to use checksums |
a100ecb120e73519aa074675a762cf3ff238c2dad36acec1a452a30a3220242a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.4
|
Release files / django_data_seeder-0.2.0-py3-none-any.whl
| Download URL | django_data_seeder-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1eae99da0b08cfcf8aee39f56b972bedb76796dc0fad076258733149d5a6128e
|
|
BLAKE2b-256 checksum How to use checksums |
b034e5fc8a4c3be1bd25dc2dc1495ec8342b9cd62a111de1a1d6a91c56429ebf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.4
|
Security for django-data-seeder 0.2.0
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.