Helper class for generate sampledata
Project description
Helper class to create django sample data.
Example
Sample data command for generate instances of MyModel:
from django.core.management.base import BaseCommand from myapp.models import MyModel from sampledatahelper.helper import SampleDataHelper class Command(BaseCommand): args = '' help = 'Example data generator' sd = SampleDataHelper(seed=12345678901) def generate_mymodel_data(self, instances): for x in range(instances): instance = MyModel.objects.create( slug=self.sd.slug(2, 3), name=self.sd.name(2, 3) claim=self.sd.sentence(), description=self.sd.paragraph(), email=self.sd.email(), photo=self.sd.image(64, 64), is_active=self.sd.boolean(), birth_date=self.sd.past_date(), expected_death_date=self.sd.future_date(), my_related_object=self.sd.db_object(MyRelatedModel) ) def handle(self, *args, **options): print "Generating MyModel data" self.generate_mymodel_data(5)
Documentation
Read the Docs: https://django-sample-data-helper.readthedocs.org/en/latest/
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
File details
Details for the file django-sampledatahelper-0.1.tar.gz
.
File metadata
- Download URL: django-sampledatahelper-0.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11da7ca85dfc3b937d00d0aea482908695164d02140c674927495c7eeb1d80e |
|
MD5 | 019017fb06d4c59461aab87ccb6ff885 |
|
BLAKE2b-256 | 217c98ffc48831cd9d40342bce0f5fe9207740ebd8b02398ed725e5cc8cb55b8 |