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
3
votes
1 answer
Django initial data fixture installation order
My fixtures are loading in an incorrect order, so they fail to install - app A creates a model with a foreign key to a model in app B, but Django tries to load the initial data for app B first.
How can I control the order in which the initial data…

Dor
- 902
- 4
- 24
3
votes
0 answers
django MPTT model and applying Fixture
I'm using django MPTT model.
I subclass MPTT model, but then try to add fixture to the custom model with supplied initial_data in JSON.
The parent TreeForeignKey is optional (blank=True, null=True)
When I apply a JSON fixture from initial_data, it…

user3044258
- 99
- 1
- 9
3
votes
1 answer
Syncronizing data between two django servers
I have a central Django server containing all of my information in a database. I want to have a second Django server that contains a subset of that information in a second database. I need a bulletproof way to selectively sync data between the…

Hayk Martiros
- 2,146
- 19
- 21
2
votes
1 answer
Django fixtures. JSONDecodeError
I've a Django project and I want to add test data to database. When I make syncdb like this
python ~/django/foo/manage.py syncdb
After tables are installed I've got an error
Problem installing fixture…

Павел Тявин
- 2,529
- 4
- 25
- 32
2
votes
1 answer
Django's syncdb is inserting duplicated entries in auth_permission table
I have created my models in django and run manage.py syncdb
Everything was ok, until I added a new model in an existing app. When I run syncdb again, duplicated entries were inserted in auth_parmission table. Even for entry log from "admin" app.
I…

duduklein
- 10,014
- 11
- 44
- 55
2
votes
1 answer
CommandError: No fixture named 'fixture' found
I'm trying to use loaddata to load some fixtures into a Django 2.2.10 project. According to the documentation, the command should look like this:
python manage.py loaddata fixture app/fixtures/*.json
However, when I run this command I get the…

Ariel
- 3,383
- 4
- 43
- 58
2
votes
0 answers
Pytest scope='module' fixture not delete model instance after testing module
I create the message instance in a fixture with scope='module', right in the test file. But when the test reaches another module, this message instance still exists in the database.
in…

Максим прокулус
- 21
- 1
- 4
2
votes
4 answers
"No fixtures found" during syncdb/schemamigration with initial_data.yaml [Django 1.3]
I have a few apps set up, to one of which I just added a fixture. I created an "initial_data.yaml" file in a subdirectory "fixtures" under the app folder, so the full path is project_dir\apps\job\fixtures\initial_data.yaml.
I've tried both
python…

Paul Zaczkowski
- 2,848
- 1
- 25
- 26
2
votes
1 answer
Generating a Django Model that can have multiple values in one field
I am trying to generate a Django model that can handle multiple values in a single field. As such, when the first field is queried through a view, a user should select a value for the second field through a select box.
To give a background of the…

karuoro
- 541
- 4
- 12
2
votes
1 answer
Django decorator to skip fixtures in tests
Is there a decorator in Django that would allow to run the test function without applying fixtures?
Something like:
from django.test import TestCase
class TestSomething(TestCase):
fixtures = ['test_fixture.json']
def…

ncopiy
- 1,515
- 14
- 30
2
votes
1 answer
How to deploy Django Fixtures to Amazon AWS
I have my app stored on GitHub. To deploy it to Amazon, I use their EB deploy command which takes my git repository and sends it up. It then runs the container commands to load my data.
container_commands:
01_migrate:
command: "django-admin.py…

Marquis Taylor
- 103
- 7
2
votes
2 answers
Have different initial_data fixtures for different stages (testing v. production)
I have an initial_data fixture that I want to load everytime except for production. I already have different settings file for production and non-production deployments.
Any suggestions on how to accomplish this?
Clarification: I do not want test…

Belmin Fernandez
- 8,307
- 9
- 51
- 75
2
votes
0 answers
Django Fixtures Deserialization Error: No JSON object could be decoded
I am trying to call python manage.py loaddata fixture_20170717.json but I get the following error:
File "C:\Users\Anon\Anaconda2\lib\json\decoder.py", line 382, in
raw_decode raise ValueError("No JSON object could be decoded")
…

James Rolfe
- 77
- 1
- 13
2
votes
2 answers
How to use some field instead of primary keys in Django 1.6 model fixtures?
I need to dump and load fixtures of model objects without usage of primary keys. The model is flat. I know about natural keys in Django, spent a lot of time reading the documentation, but all documentation has solutions only for usage natural keys…

Vladimir Chub
- 461
- 6
- 19
2
votes
0 answers
How to save a snapshot of Django test database
Background
I'm trying to replace fixtures in my unit tests with model factories (using Factory Boy). It would help for me to determine why the current unit tests are failing if I could look at the database generated by loading the fixtures and…

Jack
- 21
- 3