Faker is a Python package that generates fake data for you.

Overview

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

Faker is heavily inspired by PHP Faker, Perl Faker, and by Ruby Faker.


_|_|_|_|          _|
_|        _|_|_|  _|  _|      _|_|    _|  _|_|
_|_|_|  _|    _|  _|_|      _|_|_|_|  _|_|
_|      _|    _|  _|  _|    _|        _|
_|        _|_|_|  _|    _|    _|_|_|  _|

Latest version released on PyPI Build status of the master branch on Mac/Linux Build status of the master branch on Windows Test coverage Package license


Compatibility

Starting from version 4.0.0, Faker dropped support for Python 2 and from version 5.0.0 only supports Python 3.6 and above. If you still need Python 2 compatibility, please install version 3.0.1 in the meantime, and please consider updating your codebase to support Python 3 so you can enjoy the latest features Faker has to offer. Please see the extended docs for more details, especially if you are upgrading from version 2.0.4 and below as there might be breaking changes.

This package was also previously called fake-factory which was already deprecated by the end of 2016, and much has changed since then, so please ensure that your project and its dependencies do not depend on the old package.

Basic Usage

Install with pip:

pip install Faker

Use faker.Faker() to create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.

from faker import Faker
fake = Faker()

fake.name()
# 'Lucy Cechtelar'

fake.address()
# '426 Jordy Lodge
#  Cartwrightshire, SC 88120-6700'

fake.text()
# 'Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
#  beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt
#  amet quidem. Iusto deleniti cum autem ad quia aperiam.
#  A consectetur quos aliquam. In iste aliquid et aut similique suscipit. Consequatur qui
#  quaerat iste minus hic expedita. Consequuntur error magni et laboriosam. Aut aspernatur
#  voluptatem sit aliquam. Dolores voluptatum est.
#  Aut molestias et maxime. Fugit autem facilis quos vero. Eius quibusdam possimus est.
#  Ea quaerat et quisquam. Deleniti sunt quam. Adipisci consequatur id in occaecati.
#  Et sint et. Ut ducimus quod nemo ab voluptatum.'

Each call to method fake.name() yields a different (random) result. This is because faker forwards faker.Generator.method_name() calls to faker.Generator.format(method_name).

for _ in range(10):
  print(fake.name())

# 'Adaline Reichel'
# 'Dr. Santa Prosacco DVM'
# 'Noemy Vandervort V'
# 'Lexi O'Conner'
# 'Gracie Weber'
# 'Roscoe Johns'
# 'Emmett Lebsack'
# 'Keegan Thiel'
# 'Wellington Koelpin II'
# 'Ms. Karley Kiehn V'

Pytest fixtures

Faker also has its own pytest plugin which provides a faker fixture you can use in your tests. Please check out the pytest fixture docs to learn more.

Providers

Each of the generator properties (like name, address, and lorem) are called "fake". A faker generator has many of them, packaged in "providers".

from faker import Faker
from faker.providers import internet

fake = Faker()
fake.add_provider(internet)

print(fake.ipv4_private())

Check the extended docs for a list of bundled providers and a list of community providers.

Localization

faker.Faker can take a locale as an argument, to return localized data. If no localized provider is found, the factory falls back to the default LCID string for US english, ie: en_US.

from faker import Faker
fake = Faker('it_IT')
for _ in range(10):
    print(fake.name())

# 'Elda Palumbo'
# 'Pacifico Giordano'
# 'Sig. Avide Guerra'
# 'Yago Amato'
# 'Eustachio Messina'
# 'Dott. Violante Lombardo'
# 'Sig. Alighieri Monti'
# 'Costanzo Costa'
# 'Nazzareno Barbieri'
# 'Max Coppola'

faker.Faker also supports multiple locales. New in v3.0.0.

from faker import Faker
fake = Faker(['it_IT', 'en_US', 'ja_JP'])
for _ in range(10):
    print(fake.name())

# 鈴木 陽一
# Leslie Moreno
# Emma Williams
# 渡辺 裕美子
# Marcantonio Galuppi
# Martha Davis
# Kristen Turner
# 中津川 春香
# Ashley Castillo
# 山田 桃子

You can check available Faker locales in the source code, under the providers package. The localization of Faker is an ongoing process, for which we need your help. Please don't hesitate to create a localized provider for your own locale and submit a Pull Request (PR).

Optimizations

The Faker constructor takes a performance-related argument called use_weighting. It specifies whether to attempt to have the frequency of values match real-world frequencies (e.g. the English name Gary would be much more frequent than the name Lorimer). If use_weighting is False, then all items have an equal chance of being selected, and the selection process is much faster. The default is True.

Command line usage

When installed, you can invoke faker from the command-line:

faker [-h] [--version] [-o output]
      [-l {bg_BG,cs_CZ,...,zh_CN,zh_TW}]
      [-r REPEAT] [-s SEP]
      [-i {package.containing.custom_provider otherpkg.containing.custom_provider}]
      [fake] [fake argument [fake argument ...]]

Where:

  • faker: is the script when installed in your environment, in development you could use python -m faker instead
  • -h, --help: shows a help message
  • --version: shows the program's version number
  • -o FILENAME: redirects the output to the specified filename
  • -l {bg_BG,cs_CZ,...,zh_CN,zh_TW}: allows use of a localized provider
  • -r REPEAT: will generate a specified number of outputs
  • -s SEP: will generate the specified separator after each generated output
  • -i {my.custom_provider other.custom_provider} list of additional custom providers to use. Note that is the import path of the package containing your Provider class, not the custom Provider class itself.
  • fake: is the name of the fake to generate an output for, such as name, address, or text
  • [fake argument ...]: optional arguments to pass to the fake (e.g. the profile fake takes an optional list of comma separated field names as the first argument)

Examples:

$ faker address
968 Bahringer Garden Apt. 722
Kristinaland, NJ 09890

$ faker -l de_DE address
Samira-Niemeier-Allee 56
94812 Biedenkopf

$ faker profile ssn,birthdate
{'ssn': u'628-10-1085', 'birthdate': '2008-03-29'}

$ faker -r=3 -s=";" name
Willam Kertzmann;
Josiah Maggio;
Gayla Schmitt;

How to create a Provider

from faker import Faker
fake = Faker()

# first, import a similar Provider or use the default one
from faker.providers import BaseProvider

# create new provider class
class MyProvider(BaseProvider):
    def foo(self):
        return 'bar'

# then add new provider to faker instance
fake.add_provider(MyProvider)

# now you can use:
fake.foo()
# 'bar'

How to customize the Lorem Provider

You can provide your own sets of words if you don't want to use the default lorem ipsum one. The following example shows how to do it with a list of words picked from cakeipsum :

from faker import Faker
fake = Faker()

my_word_list = [
'danish','cheesecake','sugar',
'Lollipop','wafer','Gummies',
'sesame','Jelly','beans',
'pie','bar','Ice','oat' ]

fake.sentence()
# 'Expedita at beatae voluptatibus nulla omnis.'

fake.sentence(ext_word_list=my_word_list)
# 'Oat beans oat Lollipop bar cheesecake.'

How to use with Factory Boy

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')

Accessing the random instance

The .random property on the generator returns the instance of random.Random used to generate the values:

from faker import Faker
fake = Faker()
fake.random
fake.random.getstate()

By default all generators share the same instance of random.Random, which can be accessed with from faker.generator import random. Using this may be useful for plugins that want to affect all faker instances.

Unique values

Through use of the .unique property on the generator, you can guarantee that any generated values are unique for this specific instance.

from faker import Faker
fake = Faker()
names = [fake.unique.first_name() for i in range(500)]
assert len(set(names)) == len(names)

Calling fake.unique.clear() clears the already seen values. Note, to avoid infinite loops, after a number of attempts to find a unique value, Faker will throw a UniquenessException. Beware of the birthday paradox, collisions are more likely than you'd think.

from faker import Faker

fake = Faker()
for i in range(3):
     # Raises a UniquenessException
     fake.unique.boolean()

In addition, only hashable arguments and return values can be used with .unique.

Seeding the Generator

When using Faker for unit testing, you will often want to generate the same data set. For convenience, the generator also provide a seed() method, which seeds the shared random number generator. Calling the same methods with the same version of faker and seed produces the same results.

from faker import Faker
fake = Faker()
Faker.seed(4321)

print(fake.name())
# 'Margaret Boehm'

Each generator can also be switched to its own instance of random.Random, separate to the shared one, by using the seed_instance() method, which acts the same way. For example:

from faker import Faker
fake = Faker()
fake.seed_instance(4321)

print(fake.name())
# 'Margaret Boehm'

Please note that as we keep updating datasets, results are not guaranteed to be consistent across patch versions. If you hardcode results in your test, make sure you pinned the version of Faker down to the patch number.

If you are using pytest, you can seed the faker fixture by defining a faker_seed fixture. Please check out the pytest fixture docs to learn more.

Tests

Run tests:

$ tox

Write documentation for providers:

$ python -m faker > docs.txt

Contribute

Please see CONTRIBUTING.

License

Faker is released under the MIT License. See the bundled LICENSE file for details.

Credits

Comments
  • Move to 'faker' on Pypi

    Move to 'faker' on Pypi

    Looks like the Faker namespace on Pypi has been abandoned for quite a while: https://pypi.python.org/pypi/Faker

    This project's owner @joke2k should file a request to have the namespace transferred to this project.

    It would reduce confusion between Faker (project name) and fake-factory (how it gets pip installed).

    The pypi team is pretty good about transferring namespaces if they're clearly abandoned (which seems to be the case here).

    opened by jeffwidman 30
  • Reproducibility of results broken between Faker-0.7.18 and (Faker-0.8.0, 0.8.7)

    Reproducibility of results broken between Faker-0.7.18 and (Faker-0.8.0, 0.8.7)

    Faker-0.8.0 and Faker-0.7.18 generate different values when given the same random source.

    Is the deterministic generation a goal of the project or not? I assumed that it is before… because the README specifically says that it's useful for unit testing, which is how I use it.

    opened by sp-1234 23
  • AttributeError: 'module' object has no attribute 'Provider'   on Faker()

    AttributeError: 'module' object has no attribute 'Provider' on Faker()

    When i create a Faker class i got following error:

    ERROR: Failure: AttributeError ('module' object has no attribute 'Provider')
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
        addr.filename, addr.module)
      File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
        return self.importFromDir(dir_path, fqname)
      File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
        mod = load_module(part_fqname, fh, filename, desc)
      File "/home/rentapplication/django-rentapplication/rentapplication/tests/test_api/test_sessions.py", line 10, in <module>
        from rentapplication.tests.helpers import ReferrerFactory, LandlordFactory
      File "/home/rentapplication/django-rentapplication/rentapplication/tests/helpers.py", line 35, in <module>
        f = Faker()
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 38, in create
        prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 49, in _get_provider_class
        provider_class = cls._find_provider_class(provider, locale)
      File "/usr/local/lib/python2.7/dist-packages/faker/factory.py", line 87, in _find_provider_class
        return provider_module.Provider
    AttributeError: 'module' object has no attribute 'Provider'```
    
    opened by aldarund 22
  • Typing [Fixed #1489!]

    Typing [Fixed #1489!]

    What does this change?

    Added type annotation hints to all functions/classes in faker!

    What was wrong

    faker did not include type annotations (issue #1489).

    How this fixes it

    • Added automatic type annotations with monkeytype (https://monkeytype.readthedocs.io/en/latest/) for all files in which it did not throw errors.
    • Manual linter fixes.
    • Manual fixes of missing type annotations or unknown type annotations (e.g. type None). Did a lot of code analysis myself, but would also like to credit @nicarl for his earlier work on type annotations (e.g. in documentory.py and generator.py).
    • mypy compliant (mypy -m faker). Also added mypy -m faker test to tox.ini!
    • flake8 compliant (flake8 faker tests)
    • isort compliant (python3 -m isort --check-only --diff .)
    bump-version:minor hacktoberfest-accepted 
    opened by MarcelRobeer 21
  • 8.7.0: pytest is failing

    8.7.0: pytest is failing

    • Faker version: 8.7.0
    • OS: Linux/x86_64

    Brief summary of the issue goes here.

    Steps to reproduce

    • "python setup.py build"
    • "python setup.py install --root </install/prefix>"
    • "/usr/bin/pytest" wyth PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-faker-8.7.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-faker-8.7.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + PYTHONDONTWRITEBYTECODE=1
    + /usr/bin/pytest -ra -q --ignore tests/providers/test_ssn.py
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
    benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    rootdir: /home/tkloczko/rpmbuild/BUILD/faker-8.7.0, configfile: setup.cfg
    plugins: Faker-8.7.0, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, cases-3.6.1, flaky-3.7.0, hypothesis-6.14.0, benchmark-3.4.1
    collected 1117 items / 2 errors / 1115 selected
    
    ================================================================================== ERRORS ==================================================================================
    _____________________________________________________________ ERROR collecting tests/sphinx/test_docstring.py ______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-8.7.0/tests/sphinx/test_docstring.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/sphinx/test_docstring.py:8: in <module>
        from faker.sphinx.docstring import DEFAULT_SAMPLE_SIZE, DEFAULT_SEED, ProviderMethodDocstring, Sample
    E   ModuleNotFoundError: No module named 'faker.sphinx'
    _____________________________________________________________ ERROR collecting tests/sphinx/test_validator.py ______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-8.7.0/tests/sphinx/test_validator.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/sphinx/test_validator.py:6: in <module>
        from faker.sphinx.validator import SampleCodeValidator
    E   ModuleNotFoundError: No module named 'faker.sphinx'
    ========================================================================= short test summary info ==========================================================================
    ERROR tests/sphinx/test_docstring.py
    ERROR tests/sphinx/test_validator.py
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ============================================================================ 2 errors in 4.31s =============================================================================
    

    pytest is executed with --ignore tests/providers/test_ssn.py because https://github.com/joke2k/faker/issues/1454

    stale 
    opened by kloczek 21
  • Public IP blocks used with ipv4_public encompass reserved address namespaces

    Public IP blocks used with ipv4_public encompass reserved address namespaces

    The ipv4_public faker generates IP addresses from public blocks, excluding private blocks configured in IPV4_PUBLIC_NETS and IPV4_PRIVATE_NET_BLOCKS, however it often results in addresses coming from reserved spaces.

    One example is 192.0.0.145, or in general 192.0.0.0/24 addresses from reserved space, per https://en.wikipedia.org/wiki/Reserved_IP_addresses

    This clashes with many popular libraries checking whether IP is public and routable such as django-ipware.

    Steps to reproduce

    >>> startswith = False
    >>> while not startswith:
    ...   ip = fake.ipv4_public()
    ...   if ip.startswith('192.0.0'):
    ...     startswith = True
    ...     print(ip)
    ...
    192.0.0.145
    

    Expected behavior

    No address starting with 192.0.0 generated

    Actual behavior

    192.0.0.145 comes up often.

    opened by maticomp 19
  • Add support for multiple locale data generation

    Add support for multiple locale data generation

    What does this change

    Faker can now accept multiple locales while retaining the same signature to preserve backward compatibility.

    What was wrong

    Faker can only handle a single locale.

    How this fixes it

    The new Faker proxy class will internally create locale-specific generators as needed, and then proxy calls to the generators that can accommodate the call. Generator selection logic may also be specified via weights.

    Notes

    Needless to say, there will be a performance penalty, and the severity of the penalty depends on:

    • How many locales were specified
    • How many locale-specific generators can handle a certain call
    • If a custom distribution will be used

    Fixes #691, fixes #976, partial solution-ish to #453, related to #230

    opened by malefice 17
  • Not possible to seed uuid4

    Not possible to seed uuid4

    It is not possible to seed the uuid4 property.

    >>> f1 = Faker()
    >>> f1.seed(4321)
    >>> print(f1.uuid4())
    4a6d35db-b61b-49ed-a225-e16bc164f7cc
    
    >>> f2 = Faker()
    >>> f2.seed(4321)
    >>> print(f2.uuid4())
    b5f05be8-2f57-4a52-9b6f-5bcd03125278
    
    

    The solution is pretty much given in: http://stackoverflow.com/questions/41186818/how-to-generate-a-random-uuid-which-is-reproducible-with-a-seed-in-python

    opened by J535D165 16
  • 13.3.5: pytest is failing because it uses no longer maintained `random2` module

    13.3.5: pytest is failing because it uses no longer maintained `random2` module

    • Faker version: 13.3.5
    • OS: Linux x86/64

    Brief summary of the issue

    Looks like pytest is failing because test suite still is using outdated random2 module which was never updated for python 3.x).

    Steps to reproduce

    I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

    • python3 -sBm build -w --no-isolation
    • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
    • install .whl file in </install/prefix>
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

    Expected behavior

    pytest should not fail.

    Actual behavior

    Here is pytest output:

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra -q
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
    rootdir: /home/tkloczko/rpmbuild/BUILD/faker-13.3.5, configfile: setup.cfg
    plugins: Faker-13.3.5
    collected 1491 items / 1 error
    
    ================================================================================== ERRORS ==================================================================================
    _______________________________________________________________ ERROR collecting tests/providers/test_ssn.py _______________________________________________________________
    ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/faker-13.3.5/tests/providers/test_ssn.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    /usr/lib64/python3.8/importlib/__init__.py:127: in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    tests/providers/test_ssn.py:11: in <module>
        import random2
    E   ModuleNotFoundError: No module named 'random2'
    ============================================================================= warnings summary =============================================================================
    ../../BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/providers/person/fr_QC/__init__.py:10
      /home/tkloczko/rpmbuild/BUILDROOT/python-faker-13.3.5-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/providers/person/fr_QC/__init__.py:10: UserWarning: fr_QC locale is deprecated. Please use fr_CA.
        warnings.warn("fr_QC locale is deprecated. Please use fr_CA.")
    
    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    ========================================================================= short test summary info ==========================================================================
    ERROR tests/providers/test_ssn.py
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ======================================================================= 1 warning, 1 error in 10.95s =======================================================================
    
    help wanted 
    opened by kloczek 15
  • Add a random image provider

    Add a random image provider

    Python Image Library is used under the hood to generate a background and drawing a polygon, while forwarding the color generation to the existing color provider.

    So as not to force a dependency on Pillow for all installs, this provider will not work in absence of this library.

    A polygon shape is chosen because its the easiest drawing method to interface with random coordinates, as opposed to ellipses or alike that constrain input parameters, while still providing easily distinguishable random images, as opposed to random noise bitmaps.

    bump-version:minor hacktoberfest-accepted 
    opened by n1ngu 15
  • text-unidecode is released under the Artistic license

    text-unidecode is released under the Artistic license

    text-unidecode is released under the Artistic license v1.0, which is considered non-free by the FSF (and therefore not compatible with the GPL). I believe this clause is also of concern to commercial users of faker too:

    1. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own.

    Not being able to charge a fee for the software is problematic for those of us who are contractors, for example.

    I realise there aren't really any good alternatives (unidecode is GPL licensed as pointed out in #628 , isounidecode doesn't support Python 3), so would a patch making text-unidecode an optional dependency be acceptable?

    opened by moggers87 15
  • Add dynamic type object generator

    Add dynamic type object generator

    • Faker version: 15.3.4
    • OS: linux

    Feature request

    It would be awesome to dynamically generate object passing the type as argument. Something like:

    from typing import Type
    
    def generate_random(object_type: Type, **kwargs):
        if object_type == int:
            callable = fake.pyint
        elif object_type == float:
            callable = fake.pyfloat
        elif object_type == bytes:
            callable = fake.binary
        elif object_type == str:
            callable = fake.pystr
        elif object_type == bool:
            callable = fake.pybool
        elif object_type == dict:
            callable = fake.pydict
        elif object_type == list:
            callable = fake.pylist
        elif object_type == set:
            callable = fake.pyset
        elif object_type == tuple:
            callable = fake.pytuple
       callable(**kwargs)
    

    I took a look around and I didn't find anything providing or discussing this feature

    opened by dariocurr 1
  • Add localized `Person` providers for Belgium

    Add localized `Person` providers for Belgium

    • Faker version: 15.3.4
    • OS: Windows 11

    Faker Person providers don't support Belgian localization ('nl_BE' and 'fr_BE'; 'de_BE' later perhaps). I suggest putting Belgium on the Faker map, for which I plan drafting a PR.

    Steps to reproduce

    1. define test function
      def names(locale: str | None = None) -> list[str]:
          from faker import Faker
      
          Faker.seed(0)  # to reproduce same results
          fake = Faker(locale)
          return [fake.first_name() for _ in range(10)]
      
    2. verify 'nl_BE' gives same result as default ('en_US'), while e.g. 'nl_NL' returns localized names
      assert names('nl_BE') == names() != names('nl_NL')
      
    3. verify 'fr_BE' is rejected altogether
      try:
          names('fr_BE')
          assert False, "should not be reached"
      except AttributeError:
          pass
      

    Expected behavior

    Localized names should be returned for both 'nl_BE' and 'fr_BE'.

    Actual behavior

    Currently, 'nl_BE' returns default ('en_US') names and 'fr_BE' fails.

    opened by Dutcho 0
  • Fix name_female generates mixed names (#1770)

    Fix name_female generates mixed names (#1770)

    What does this change

    Split formats in person/en_GB into formats_female and formats_male.

    What was wrong

    faker.name_female() and faker.name_male() would previously generate mixed names (both female and male names) when using locale en_GB.

    How this fixes it

    formats_female and formats_male are now defined and will no longer fall back on the general format when calling name_female() or name_male().

    Fixes #1770

    opened by nathanael-e 0
  • Suggestion: Generate Date Time values only for at certain times (e.g. Workdays, Weekends)

    Suggestion: Generate Date Time values only for at certain times (e.g. Workdays, Weekends)

    Hi,

    Using fake.date_time() or fake.date_time_between() return values that are quite unrealistic for certain purposes. For my usecase I would love to have a feature that restrict the returned dates to only working days (mon-fri), maybe even only typical working hours (e.g. 08:00-17:00).

    I could imagine that as an optional parameter in the function call: fake.date_time_between(filter="weekdays")

    Other filters could be "weekend", "monday", "nighttime", "daytime" etc.

    opened by SevHub 1
  • Suggestion: generate valid data for barcode structures

    Suggestion: generate valid data for barcode structures

    • Faker version: 15.3.4
    • OS: Windows

    Suggestion: faker already includes functions to generate simple 1d barcodes (ean8 and ean13) plus a few more. In the barcode world there are many other data structures which would be useful to fake.

    I work professionally with barcodes from a customer pov. and often come across some of these:

    • GS1 structure
    • German Post (premium post)
    • UK Royal Mail datamatrix
    • Swiss QR code
    • vcard structure
    • UPU parcel code

    In principle these are just appearing as "random strings", but the data format has to be in a very specific way. It would be very useful to generate such structures and feed to a barcode generator.

    opened by myicq 1
Releases(v15.3.4)
Owner
Daniele Faraglia
Web-native developer, UK based Self-employed
Daniele Faraglia
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 1, 2022
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango.

The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango. It requires a django-leaflet package.

Vsevolod Novikov 33 Nov 11, 2022
A standalone package to scrape financial data from listed Vietnamese companies via Vietstock

Scrape Financial Data of Vietnamese Listed Companies - Version 2 A standalone package to scrape financial data from listed Vietnamese companies via Vi

Viet Anh (Vincent) Tran 45 Nov 16, 2022
DCM is a set of tools that helps you to keep your data in your Django Models consistent.

Django Consistency Model DCM is a set of tools that helps you to keep your data in your Django Models consistent. Motivation You have a lot of legacy

Occipital 59 Dec 21, 2022
Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in the browser cookies.

Django Persistent Filters Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in

Lorenzo Prodon 2 Aug 5, 2022
Mobile Detect is a lightweight Python package for detecting mobile devices (including tablets).

Django Mobile Detector Mobile Detect is a lightweight Python package for detecting mobile devices (including tablets). It uses the User-Agent string c

Botir 6 Aug 31, 2022
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django ?? Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 9, 2022
A package to handle images in django

Django Image Tools Django Image Tools is a small app that will allow you to manage your project's images without worrying much about image sizes, how

The Bonsai Studio 42 Jun 2, 2022
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.7k Jan 2, 2023
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 7, 2023
Helps working with singletons - things like global settings that you want to edit from the admin site.

Django Solo +---------------------------+ | | | | | \ | Django Solo helps

Sylvain Toé 726 Jan 8, 2023
pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-dev 1.1k Dec 14, 2022
The best way to have DRY Django forms. The app provides a tag and filter that lets you quickly render forms in a div format while providing an enormous amount of capability to configure and control the rendered HTML.

django-crispy-forms The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered

null 4.6k Jan 7, 2023
A Django web application that allows you to be in the loop about everything happening in your neighborhood.

A Django web application that allows you to be in the loop about everything happening in your neighborhood. From contact information of different handyman to meeting announcements or even alerts.

Kennedy Ngugi Mwaura 3 Dec 11, 2022
An app that allows you to add recipes from the dashboard made using DJango, JQuery, JScript and HTMl.

An app that allows you to add recipes from the dashboard. Then visitors filter based on different categories also each ingredient has a unique page with their related recipes.

Pablo Sagredo 1 Jan 31, 2022
A visual indicator of what environment/system you're using in django

A visual indicator of what environment/system you're using in django

Mark Walker 4 Nov 26, 2022
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

null 2.6k Dec 26, 2022
A reusable Django model field for storing ad-hoc JSON data

jsonfield jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.

Ryan P Kilby 1.1k Jan 3, 2023