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

install: pip install django-easy-fixture

1. output a fixture dict

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

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.1.3.tar.gz (13.1 kB view hashes)

Uploaded Source

Built Distribution

django_easy_fixture-0.1.3-py2.py3-none-any.whl (6.3 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