Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

easy to create a django fixture

Project description

.. figure::

python2.7, python3.5

1.8<= Django <= 1.10

**install: pip install django-easy-fixture**

That is a easy, simple tool to help you to fill your fixture dict with some spam datas

Make your fixture dict to be a completely available django fixture that **you do not have to worry about any unqiue, unqie_together, just pk**

**The pk must be defined by you!**

**Just support all the fields defined by Django, and do not support any customization field.**

**Maybe** support the customization field in the future.

1. get a fixture dict

.. code-block:: python

# in
fixtures_template={'auth.User': [{'pk': 1}]}

# in
from easy_fixture.easy_fixture import EasyFixture
from template import fixtures_template

ef = EasyFixture(fixtures_template)
fixtures_dict = ef.output()

2. use as a django app command

.. code-block:: python

# in
fixtures_template = {'auth.User': [{'pk': 1}]}

# in your
INSTALLED_APPS = ('other apps',
run make_fixture command

.. code-block:: python

python make_fixture template.fixtures_template > /path/to/fixture.json

Must pass the module path and fixture variable, like

**do not support old style**

.. code-block:: python

python make_fixture template > /path/to/fixture.json

3. use in test

In your testCase, call EasyFixture.load_into_testcase in your setUpTestData, setUpClass, setUp or anywhere you want to load your fixture data.

.. code-block:: python

FIXTURE_DICT = {'auth.User': [{'pk': 1}]}

class MyTestCase(TestCase):

def setUpTestData(cls):
ef = EasyFixture(FIXTURE_DICT)

def tes_what_you_want(self):


.. code-block:: python

from easy_fixture.easy_fixture import FixtureFileGen

class MyCase(TestCase):
fixtures = FixtureFileGen(['my.fixture.template.module'])

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django_easy_fixture-0.3.0-py2.py3-none-any.whl (6.7 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Nov 24, 2016
django-easy-fixture-0.3.0.tar.gz (13.3 kB) Copy SHA256 hash SHA256 Source None Nov 24, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page