{ "info": { "author": "joke2k", "author_email": "joke2k@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing", "Topic :: Software Development :: Widget Sets", "Topic :: Utilities" ], "description": "Django-faker\n============\n\n*Django-faker* uses `PyFaker`_ to generate test data for Django models and templates.\n\nHow to use\n----------\n\nTo install Django-faker you can use pip::\n\n pip install django-faker\n\n\nConfiguration\n~~~~~~~~~~~~~\n\nIn django application `settings.py`::\n\n INSTALLED_APPS = (\n\n # ...\n 'django_faker',\n )\n\n FAKER_LOCALE = None # settings.LANGUAGE_CODE is loaded\n FAKER_PROVIDERS = None # faker.DEFAULT_PROVIDERS is loaded (all)\n\n\nPopulating Django Models\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n*Django-faker* provides an adapter for Django Models, for easy population of test databases.\nTo populate with Model instances, create a new Populator class,\nthen list the class and number of all of Models that must be generated. To launch the actual data population,\ncall `execute()` method.\n\nHere is an example showing how to populate 5 `Game` and 10 `Player` objects::\n\n from django_faker import Faker\n # this Populator is only a function thats return a django_faker.populator.Populator instance\n # correctly initialized with a faker.generator.Generator instance, configured as above\n populator = Faker.getPopulator()\n\n from myapp.models import Game, Player\n populator.addEntity(Game,5)\n populator.addEntity(Player,10)\n\n insertedPks = populator.execute()\n\nThe populator uses name and column type guessers to populate each column with relevant data.\nFor instance, Django-faker populates a column named `first_name` using the `firstName` formatter, and a column with\na `datetime` instance using the `dateTime`.\nThe resulting entities are therefore coherent. If Django-faker misinterprets a column name, you can still specify a custom\nfunction to be used for populating a particular column, using the third argument to `addEntity()`::\n\n\n populator.addEntity(Player, 10, {\n 'score': lambda x: populator.generator.randomInt(0,1000),\n 'nickname': lambda x: populator.generator.email(),\n })\n populator.execute()\n\nOf course, Django-faker does not populate autoincremented primary keys.\nIn addition, `django_faker.populator.Populator.execute()` returns the list of inserted PKs, indexed by class::\n\n print insertedPks\n {\n : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n : [1, 2, 3, 4, 5]\n }\n\nIn the previous example, the `Player` and `Game` models share a relationship. Since `Game` entities are populated first,\nFaker is smart enough to relate the populated `Player` entities to one of populated `Game` entities.\n\n\nTemplate tags and filter\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nDjango-faker offers a useful template tags and filters for interact with `PyFaker`_::\n\n {% fake 'name' as myname %}{% fake 'dateTimeBetween' '-10d' as mydate %}\n\n {{ myname|title }} - {{ mydate|date:\"M Y\" }}\n\n\n\n {% load fakers %}\n\n \n \n {% fake 'randomInt' 10 20 as times %}\n {% for i in 10|get_range %}\n \n \n {% if 'boolean'|fake:25 %}\n \n {% endif %}\n
\n {% fakestr 'streetAddress' %}\n {% fakestr 'city' %}\n {% fakestr 'postcode' %}\n {% fakestr 'state' %}\n
\n \n {% if 'boolean'|fake:25 %}\n {% fakestr 'bs' %}\n {% endif %}\n {% if 'boolean'|fake:33 %}\n \n {% endif %}\n \n {% if 'boolean'|fake:15 %}\n
\n \n
\n {% endif %}\n
\n {% endfor %}\n
\n\n\nPage preview\n~~~~~~~~~~~~\nOpen `url.py` in your main application and add this url::\n\n urlpatterns = patterns('',\n ...\n url(r'', include('django_faker.urls')),\n ...\n )\n\nhttp://127.0.0.1:8000/preview/ shows a faked browser windows, useful for screenshots.\n\nRunning the Tests\n-----------------\n\nRun django tests in a django environment:\n\n $ python runtests.py\n\nor if you have 'django_faker' in INSTALLED_APPS:\n\n $ python manage.py test django_faker\n\n\n.. _PyFaker: https://www.github.com/joke2k/faker/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/joke2k/django-faker", "keywords": "faker fixtures data test django", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-faker", "package_url": "https://pypi.org/project/django-faker/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-faker/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/joke2k/django-faker" }, "release_url": "https://pypi.org/project/django-faker/0.2/", "requires_dist": null, "requires_python": null, "summary": "Django-faker uses python-faker to generate test data for Django models and templates.", "version": "0.2" }, "last_serial": 789618, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "931d2e8d6d0b649024a8c44fe85c8c3e", "sha256": "47b2ff7f878fcd06801ce52eb7fbb81f1f96194efc0b0ab3b1d55e1765aea86d" }, "downloads": -1, "filename": "django-faker-0.1.tar.gz", "has_sig": false, "md5_digest": "931d2e8d6d0b649024a8c44fe85c8c3e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9520, "upload_time": "2013-01-07T13:13:35", "url": "https://files.pythonhosted.org/packages/3e/ca/f7e1785dbd2590055a2514279d424eab97224997bc5594dc92ae84592c7a/django-faker-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "7e84b3f2f636d3f471cba503fdd6b355", "sha256": "436ba41be27bb810ab953e30fb458b79de282849153602cd2e7cfe1546c204b9" }, "downloads": -1, "filename": "django-faker-0.2.tar.gz", "has_sig": false, "md5_digest": "7e84b3f2f636d3f471cba503fdd6b355", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9581, "upload_time": "2013-01-24T13:07:25", "url": "https://files.pythonhosted.org/packages/01/5a/c901e3cbdee2355d37ae74aeeaec15750756e35c62d44a233cc89486dcd8/django-faker-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e84b3f2f636d3f471cba503fdd6b355", "sha256": "436ba41be27bb810ab953e30fb458b79de282849153602cd2e7cfe1546c204b9" }, "downloads": -1, "filename": "django-faker-0.2.tar.gz", "has_sig": false, "md5_digest": "7e84b3f2f636d3f471cba503fdd6b355", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9581, "upload_time": "2013-01-24T13:07:25", "url": "https://files.pythonhosted.org/packages/01/5a/c901e3cbdee2355d37ae74aeeaec15750756e35c62d44a233cc89486dcd8/django-faker-0.2.tar.gz" } ] }