Package: djipsum
Django Lorem Ipsum Generator - Command plugin to generate (fake content data) for Django model, and usesFaker Factorypackage for API Faker Model.InstallDjipsum is available directly fromPyPI:$ pip install djipsum*).And don’t forget to adddjipsumto yourINSTALLED_APPSsetting(without migrations).RequirementsDjango>=1.10.1Faker>=0.7.3Usageusage: djipsum -h [-h] [-dv] [-auto] [-cg CUSTOM_GENERATOR]
                  [--app APP] [--model MODEL] [--max MAX]

To generate awesome lorem ipsum for your model!

optional arguments:
  -h, --help            show this help message and exit
  -dv, --djipsum_version
                        Show djipsum version number and exit.
  -auto, --auto_gen     Automatic generate lorem ipsum from custom generator
                        class.
  -cg, --custom_generator CUSTOM_GENERATOR
                        Custom a function generator (full path) for auto-gen.
  --app APP             The app name.
  --model MODEL         The model class name.
  --max MAX             Maximum generate lorem ipsum.Example# Default 10 objects
$ ./manage.py djipsum --app testapp --model TestField

# Custom Maximum objects
$ ./manage.py djipsum --app testapp --model TestField --max=5APIThe Djipsum Faker Model providing additional library fromFaker Factoryfor more than efficient to use.1. Basic API>>> from djipsum.faker import FakerModel
>>> faker = FakerModel(app='app_name', model='ModelName')
>>> faker.fake_email() # From Djipsum
'admin@gmail.com'
>>> faker.fake.email() # From Faker Factory
'smithadrian@hotmail.com'
>>>2. Example API Usage>>> from djipsum.faker import FakerModel
>>> faker = FakerModel(app='app_blog', model='Post')
>>> for _ in range(2):
...     fields = {
...         'user': faker.fake_relations(
...             type='fk',
...             field_name='user'
...         ),
...         'title': faker.fake.text(max_nb_chars=100),
...         'slug': faker.fake.slug(
...             faker.fake.text(max_nb_chars=50)
...         ),
...         'categories': faker.fake_relations(
...             type='m2m',
...             field_name='categories'
...         ),
...         'description': ' '.join(faker.fake.paragraphs()),
...         'created': str(faker.fake.date_time()),
...         'publish': faker.fake_boolean(),
...     }
...     faker.create(fields)
...
<Post: Sit sunt nam aperiam ratione consequatur. Animi cupiditate atque totam.>
<Post: Tempora porro sint quasi nisi totam doloremque repellat. Ducimus nesciunt impedit animi.>
>>>3. Using custom Management commandThis an example to create custom special faker file as a tool for unittests.
For example i need to save this script into file ofapp_blog.blogfaker.pyfrom djipsum.faker import FakerModel


def postfaker(maximum=10):
    """
    Sample custom generator.
    Djipsum already handled with `--max` command.
    But, recomended to set default integer `maximum` like above.
    """
    faker = FakerModel(
        app='app_blog',
        model='Post'
    )
    object_list = [] # for print out after created the objects.

    for _ in range(maximum):
        fields = {
            'user': faker.fake_relations(
                type='fk',
                field_name='user'
            ),
            'title': faker.fake.text(max_nb_chars=100),
            'slug': faker.fake.slug(
                faker.fake.text(max_nb_chars=50)
            ),
            'categories': faker.fake_relations(
                type='m2m',
                field_name='categories'
            ),
            'description': ' '.join(faker.fake.paragraphs()),
            'created': str(faker.fake.date_time()),
            'publish': faker.fake_boolean(),
        }
        instance = faker.create(fields)
        object_list.append(instance)
    return object_listAnd then, you also can access it via djipsum command such as below. This should be create2objects../manage.py djipsum --auto_gen --custom_generator=app_blog.blogfaker.postfaker --max=2

# OR

./manage.py djipsum -auto -cg=app_blog.blogfaker.postfaker --max=2Supported FieldsChar TypesInteger/Float TypesRelationship TypesOther TypesCharFieldIntegerFieldForeignKeyBinaryFieldTextFieldSmallIntegerFieldManyToManyFieldDurationFieldEmailFieldBigIntegerFieldOneToOneField (not yet)BooleanFieldSlugFieldDecimalFieldOneToManyField (not yet)NullBooleanFieldURLFieldPositiveIntegerFieldUUIDFieldFloatFieldGenericIPAddressFieldPositiveSmallIntegerFieldCommaSeparatedIntegerFieldDateTimeFieldDateFieldTimeFieldImageFieldFileFieldFilePathField (not yet)Refference Faker Model Fieldsfake = <faker.generator.Generator object>Providing the package from Faker Factory.djipsum_fields(self)Extended from classDjipsumFieldsfor some special fields.fake_binary(self)Return random binary format.
Faker Factory also provide about this binary.Example:b"\x00\x01\x02\x03\x04\x05\x06\x07",b"\x0b\x0c\x0e\x0f", etc.from Djipsumfaker.fake_binary()from Faker Factoryfaker.fake.binary(length=10)fake_chars_or_choice(self, field_name)Return fake chars or choice it if thefield_namehas choices.
Then, returning random value from it. This specially forCharField.Usage:faker.fake_chars_or_choice('field_name')Example for field:TYPE_CHOICES = (
  ('project', 'I wanna to talk about project'),
  ('feedback', 'I want to report a bugs or give feedback'),
  ('hello', 'I just want to say hello')
)
type = models.CharField(max_length=200, choices=TYPE_CHOICES)fake_comma_separated_integer(self)Return the unique integers in the string.
This specially forCommaSeparatedIntegerField.Example:'6,1,7','4,5,1,3,2','2,7,9,3,5,4,1'fake_decimal(self, field_name)Validate if the field has amax_digitsanddecimal_placesAnd generating the unique decimal number.Usage:faker.fake_decimal('field_name')Example:10.7,13041.00,200.000.000fake_boolean(self)Example:True, Falsefake_null_boolean(self)Faker Factory also provide about this null boolean.Example:None,True,Falsefrom Djipsumfaker.fake_null_boolean()from Faker Factoryfaker.fake.null_boolean()fake_float(self)Example:0.69,20.55,98.12fake_email(self)Faker Factory also provide about this email.Example:'agus@python.web.id','sample@gmail.com','hello@yahoo.com'from Djipsumfaker.fake_email()from Faker Factoryfaker.fake.email()fake_file(self)Return string name of file.
Faker Factory also provide about this file.Example:'file.zip','awesomefile.tar.gz','samplefile.docx','djipsum.pdf'from Djipsumfaker.fake_file()from Faker Factoryfaker.fake.file_name()fake_image(self)Return string name of image.Example:'avatar.jpg','djipsum.jpeg','sampleimage.png','awesome_django.gif'fake_ipaddress(self)Faker Factory also provide about this ipaddress,
such as ipv4, ipv6, …etcExample:'192.168.1.1','66.249.65.54','255.255.255.0','2001:db8:a0b:12f0::1'from Djipsumfaker.fake_ipaddress()from Faker Factoryfaker.fake.ipv4(),faker.fake.ipv6()fake_slug(self)Optionall unique slug withuuidto handleunique=True.
Faker Factory also provide about this slug.Example:this-my-slug,hello-world-93daf03138dsa0from Djipsumfaker.fake_slug()from Faker Factoryfaker.fake.slug(faker.fake.text(max_nb_chars=50))fake_paragraphs(self)Generate the paragraphs forTextField.
Faker Factory also provide about this paragraphs.Example:from Djipsumfaker.fake_paragraphs()from Faker Factory''.join(faker.fake.paragraphs())fake_url(self)Generate the url forURLField.
Faker Factory also provide about this url.Example:https://python.web.id,http://dracos-linux.orgfrom Djipsumfaker.fake_url()from Faker Factoryfaker.fake.url()fake_uuid(self)Generate the unique uuid
fromuuid1,uuid3,uuid4, oruuid5.Example:fb3d6e7f82db47dcaaca46bdd82b24a5,886313e13b8a53729b900c9aee199e5dfake_relations(self, type, field_name)Return the dictionary of object/s relation
to process the Relationship.Example:Foreign Key:faker.fake_relations(type='fk',field_name='author')Many To Many:faker.fake_relations(type='m2m',field_name='categories')LicenseMIT