You can use python providers as well.

class MyModel(factory.django.DjangoModelFactory)
  number_field = factory.Faker('pyint', min_value=0, max_value=1000)
  class Meta:
    model = SomeModel

Documentation

Answer from Gonzalo on Stack Overflow
🌐
Faker
faker.readthedocs.io › en › master › providers › faker.providers.python.html
faker.providers.python — Faker 40.12.0 documentation
pystr_format(string_format: str = '?#-###{{random_int}}{{random_letter}}', letters: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') → str¶ ... >>> Faker.seed(0) >>> for _ in range(5): ... fake.pystr_format() ...
🌐
Faker
faker.readthedocs.io › en › master › providers › baseprovider.html
faker.providers. - BaseProvider - Faker's documentation!
If digits is None (default), its value will be set to a random integer from 1 to 9. If fix_len is False (default), all integers that do not exceed the number of digits can be generated. If fix_len is True, only integers with the exact number of digits can be generated.
🌐
ZetCode
zetcode.com › python › faker
Python Faker - generating fake data in Python with Faker module
January 29, 2024 - The Faker allows to generate random digits and integers. fake_numbers.py · #!/usr/bin/python from faker import Faker faker = Faker() print(f'Random int: {faker.random_int()}') print(f'Random int: {faker.random_int(0, 100)}') print(f'Random digit: {faker.random_digit()}') The example generates ...
🌐
GitHub
github.com › joke2k › faker
GitHub - joke2k/faker: Faker is a Python package that generates fake data for you. · GitHub
Factory Boy already ships with integration with Faker. Simply use the factory.Faker method of factory_boy: import factory from myapp.models import Book class BookFactory(factory.Factory): class Meta: model = Book title = factory.Faker('sentence', nb_words=4) author_name = factory.Faker('name') The .random property on the generator returns the instance of random.Random used to generate the values:
Starred by 19.2K users
Forked by 2.1K users
Languages   Python
🌐
CodingNomads
codingnomads.com › how-to-use-python-faker-random-data-generator
How to Use Python Faker: Random Data Generator
Using the faker.Faker class, you can generate all sorts of dummy data, like emails, usernames, and even dates in the past, using Faker's random data generator. Sometimes, a Faker object can generate duplicate data. It's best to catch the IntegrityError exception that SQLAlchemy would otherwise throw, and then do a db.session.rollback() to undo the duplicate user.
Find elsewhere
🌐
DEV Community
dev.to › dev_neil_a › python-how-to-create-sample-data-using-faker-co4
Python How-To: Create Sample Data Using Faker - DEV Community
October 20, 2024 - Prior to using faker, it will need to be installed as it is a third-party library that is not part of the base Python library collection. To do this, use the pip command in the terminal as follows: ... The following example will generate three addresses and peoples names, each of which will be a dictionary that will be added to a list. # --- 1. Import the required libraries: from faker import Faker from random import randint # --- 2.
🌐
Linux Hint
linuxhint.com › python-faker-generate-dummy-data
How to Use Python Faker to Generate Dummy Data – Linux Hint
Different types of random numbers can be generated by using the faker library. Create a Python file with the following script that will generate three types of random numbers. The random_int() function will generate a random integer number. The random_number(digit=5) function will generate ...
🌐
GitHub
gist.github.com › rg3915 › 744aacde209046901748
Generate random values with Python gen_random faker gen_date fake gen date fake · GitHub
Generate random values with Python gen_random faker gen_date fake gen date fake - gen_random_values.py
🌐
Faker
faker.readthedocs.io › en › master › providers › faker.providers.misc.html
faker.providers.misc — Faker 40.11.1 documentation
boolean(chance_of_getting_true: int = 50) → bool¶ · Generate a random boolean value based on chance_of_getting_true. ... >>> Faker.seed(0) >>> for _ in range(5): ... fake.boolean(chance_of_getting_true=25) ...
🌐
Blue Book
lyz-code.github.io › blue-book › coding › python › faker
Faker - The Blue Book
from random import SystemRandom @pytest.fixture(scope="session", autouse=True) def faker_seed() -> int: """Create a random seed for the Faker library.""" return SystemRandom().randint(0, 999999)
🌐
PyPI
pypi.org › project › Faker
Faker · PyPI
When using Faker for unit testing, you will often want to generate the same data set. For convenience, the generator also provides a seed() method, which seeds the shared random number generator.
      » pip install Faker
    
Published   Mar 30, 2026
Version   40.12.0
🌐
Faker
faker.readthedocs.io › en › stable › providers › faker.providers.python.html
faker.providers.python — Faker 40.4.0 documentation
pystr_format(string_format: str = '?#-###{{random_int}}{{random_letter}}', letters: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') → str¶ ... >>> Faker.seed(0) >>> for _ in range(5): ... fake.pystr_format() ...
🌐
Readthedocs
maleficefakertest.readthedocs.io › en › latest › providers › faker.providers.python.html
faker.providers.python — Faker 4.5.0 documentation
pystr_format(string_format='?#-###{{random_int}}{{random_letter}}', letters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')¶ · >>> Faker.seed(0) >>> for _ in range(5): ... fake.pystr_format() ... 'z6-0486311W' 'h5-9384969E' 'Z1-9482289W' 'y4-1159861j' 'Y6-5931649w' pystruct(count=10, value_types=None, *allowed_types)¶ ·
🌐
Medium
medium.com › shilstack › how-to-add-fake-data-using-faker-module-in-django-dbc15c8c6552
Generating Dummy Data with Python’s Faker Module: A Complete Guide | by Prosenjeet Shil | shilstack | Medium
November 25, 2024 - # views.py from django.shortcuts import render from django.http import HttpResponse from .models import Student from faker import Faker # Create your views here. def add_fake_data(request): fake = Faker() for _ in range(10): # Generating 10 fake students Student.objects.create( name=fake.name(), roll_number=fake.random_int(min=1000, max=9999), age=fake.random_int(min=15, max=18), grade=fake.random_element(elements=('A', 'B', 'C', 'D'))
🌐
Faker
faker.readthedocs.io
Welcome to Faker’s documentation! — Faker 40.12.0 documentation
When using Faker for unit testing, you will often want to generate the same data set. For convenience, the generator also provides a seed() method, which seeds the shared random number generator.