Skip to main content

easy to create a django fixture

Project description

https://travis-ci.org/allenling/django-easy-fixture.svg?branch=master

for python2.7, python3.5 and Django>=1.8

Create a fixture dict that just include some fields you concern, and we will help you to fill your fixture dict with some spam datas that make your fixture dict to be a completely available django fixture that you do not have to worry about any unqiue, unqie_together

install: pip install django-easy-fixture

1. output a fixture dict

pk must be set by yourself

in template.py

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

then

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

2.1. create a simple fixture template

in template.py

pk must be set by yourself

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

2.2. in settings.py

INSTALLED_APPS = ('other apps',
                  'easy_fixture',
                  )

2.3. run command

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

3. use in test

from easy_fixture.easy_fixture import FixtureFileGen

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

Project details


Download files

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

Source Distribution

django-easy-fixture-0.2.1.tar.gz (13.7 kB view hashes)

Uploaded Source

Built Distribution

django_easy_fixture-0.2.1-py2.py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page