https://github.com/clearcodehq/django-data-faker
Fake-factory to generate test data for Django models via model_mommy recipes
https://github.com/clearcodehq/django-data-faker
Last synced: about 1 year ago
JSON representation
Fake-factory to generate test data for Django models via model_mommy recipes
- Host: GitHub
- URL: https://github.com/clearcodehq/django-data-faker
- Owner: ClearcodeHQ
- License: lgpl-3.0
- Created: 2013-11-07T09:58:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-13T12:14:43.000Z (over 12 years ago)
- Last Synced: 2025-03-30T13:37:08.078Z (about 1 year ago)
- Language: Python
- Size: 439 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: COPYING
Awesome Lists containing this project
README
django-data-faker
=================
Fake-factory to generate test data for Django models.
This is a mix of:
* Python Faker - https://github.com/joke2k/faker
* Model Mommy - https://github.com/vandersonmota/model_mommy
Installation
------------
To install Django-data-faker you can use pip::
pip install django-data-faker
Extra generators
----------------
**Base import**
.. code-block:: python
>>> from django_data_faker import fake
**Url with username**
.. code-block:: python
>>> fake.url_with_username()
'http://koeppledner.biz/curtis.lakin'
**Facebook url**
.. code-block:: python
>>> fake.facebook_url()
'http://facebook.com/rchristiansen'
**Twitter url**
.. code-block:: python
>>> fake.twitter_url()
'http://twitter.com/cummerata.norbert'
**LinkedIn url**
.. code-block:: python
>>> fake.linkedin_url()
'http://linkedin.com/pub/bweimann'
**Random file from directory**
.. code-block:: python
# random avatar
from myapp.models import UserProfile
user = UserProfile.objects.get(id=100)
user.avatar = fake.random_file_from_folder('/path/to/avatars/dir')
user.save()
**Generate image placeholder**
.. code-block:: python
# generate avatar placeholder
from myapp.models import UserProfile
user = UserProfile.objects.get(id=100)
user.avatar = fake.placeholder_image(400, 200)
user.save()
Example:
.. image:: http://i.imgur.com/wk8ZjIV.png?1