forked from alex/django-fixture-generator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.txt
32 lines (23 loc) · 1.01 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
``django-fixture-generator``
============================
Requires Django 1.2.
* Add ``"fixture_generator"`` to your ``INSTALLED_APPS`` setting.
* Create a ``fixture_gen.py`` file in one of your apps. It should look
something like:
from fixture_generator import fixture_generator
from django.contrib.auth.models import User, Group
@fixture_generator(User, requires=["my_app.test_groups"])
def test_users():
muggles, wizards = Group.objects.order_by("name")
simon = User.objects.create(username="simon")
adrian = User.objects.create(username="adrian")
jacob = User.objects.create(username="jacob")
simon.groups.add(wizards)
adrian.groups.add(muggles)
jacob.groups.add(muggles)
@fixture_generator(Group)
def test_groups():
Group.objects.create(name="Muggles")
Group.objects.create(name="Wizards")
* Run ``manage.py generate_fixture my_app.test_users``.
* Save the resulting fixture somewhere.