A fixture is a collection of data that Django knows how to import into a database, can be written as XML, YAML, or JSON documents. They can be used to provide initial data for models.
Questions tagged [django-fixtures]
187 questions
34
votes
12 answers
Load Multiple Fixtures at Once
Is there anyway to load one fixture and have it load multiple fixtures?
I'd ideally like to type:
python manage.py loaddata all_fixtures
And have that load all of the data instead of having to type everything. Is this possible?

silent1mezzo
- 2,814
- 4
- 26
- 46
25
votes
2 answers
IntegrityError when loading fixture during django testing
I'm loading a fixture created with dumpdata, and getting the following exception:
Problem installing fixture 'db_dump.json': Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/management/commands/loaddata.py",…

Marcin
- 48,559
- 18
- 128
- 201
23
votes
2 answers
Images in Django fixtures?
I was looking at Django fixtures in the docs, there was no mention of preloading images into the database. I can't be the only who needed to do this. Is this possible? If so how? If not, are there any workarounds available?
Please and thank you.

Mahdi Yusuf
- 19,931
- 26
- 72
- 101
23
votes
1 answer
How can I create prettier fixtures with manage.py dumpdata?
I'm trying to get my Django fixtures printed in a prettier way.
I've outputting the fixtures:
python manage.py dumpdata >> fixture_app.json
This creates a file with 1000's of characters all on one line.
When I try to view the file with my Text…

BryanWheelock
- 12,146
- 18
- 64
- 109
21
votes
2 answers
How to add superuser in Django from fixture
How to add SUPERuser(not just user) through Django fixtures?
Let's say I wanna have login:admin, password:admin.

GriMel
- 2,272
- 5
- 22
- 40
19
votes
4 answers
How can I make a fixture out of QuerySet in django?
Django dumpdata command is broken because it does not support any reasonable way to narrow down the amount of data dumped. I need to create a fixture of various querysets (and I don't need to take care about dumping objects from outer models…

pielgrzym
- 1,647
- 3
- 19
- 28
18
votes
3 answers
Django Sites Framework: Initial Data Migration Location
Before Django 1.7, when using the Django Sites Framework one could/should define the initial data using Initial Fixtures.
myproject/fixtures/initial_data.json
[
{
"pk": 1,
"model": "sites.site",
"fields": {
"domain":…

JCJS
- 3,031
- 3
- 19
- 25
14
votes
2 answers
Is DateTimeField with auto_now_add option enabled must has value in fixtures
I have model created field configurated as follows:
created = models.DateTimeField(auto_now_add=True)
In JSON fixtures I don't want to declare value for created, but when I try to load fixtures (loadata) I am getting error:
created may not be…

keram
- 2,321
- 4
- 24
- 29
13
votes
1 answer
Django loaddata ignore existing objects
I have a fixture with list of entries. eg:
[
{
"fields": {
"currency": 1,
"price": "99.99",
"product_variant": 1
},
"model": "products.productprice",
"pk": 1
},
{
"fields": {
"currency": 2,
…

Quba
- 4,776
- 7
- 34
- 60
11
votes
0 answers
Django 1.4: How to ignore fields, models in loaddata
We have a compressed dumpdata of 15MB upload extracting goes to 100MB.
It has few models & fields that are not used in current tables.
Specifically, there are few contenttypes models which can be ignored, and one field field_ that can be ignored in…

Iamcool
- 1,387
- 2
- 12
- 24
11
votes
2 answers
Django Test Complaining about Fixture
Dumped data python manage.py dumpdata --format json --indent 4 --exclude auth.permission --exclude contenttypes > app/fixtures/app_test_data.json
Running python manage.py test app, I get the following error:
IntegrityError: Problem installing…

masonjarre
- 821
- 1
- 8
- 15
10
votes
3 answers
Django testing and ContentType generic relatations fixtures
How do I use GenericRelations in Django unit testing?
I have read and tried countless suggestions on the internets to no avail.
This one was promising Problems with contenttypes when loading a fixture in Django
but "reset" command is no longer…

user3138929
- 369
- 5
- 18
8
votes
1 answer
Migrating django admin auth.groups and users to a new database using fixtures
Here's the scenario:
I'm using django's admin interface and I would like to be able to load users and groups via fixtures (if this is possible.) I'm able to dump users/groups like so:
manage.py dumpdata auth auth.group > usersandgroups.json
But…

musashiXXX
- 4,192
- 4
- 22
- 24
8
votes
1 answer
Django, generic relations, make fixtures
I'm trying to add generic relations and one-to-one relations support for django-test-utils makefixture command, here is the source http://github.com/ericholscher/django-test-utils/blob/master/test_utils/management/commands/makefixture.py
Does…

Roman Dolgiy
- 1,521
- 1
- 15
- 21
8
votes
2 answers
How to create per-project initial_data fixtures in Django 1.7+
Before Django 1.7 I used to define a per-project fixtures directory in the settings:
FIXTURE_DIRS = ('myproject/fixtures',)
and use that to place my initial_data.json fixture storing the default groups essential for the whole project. This has been…

knaperek
- 2,113
- 24
- 39