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
8
votes
2 answers
Django manage.py test cannot load fixture properly
I've written Django tests using django.test.TestCase, and I'd like to use a fixture with all of my current database data to run the tests. However, if I create the fixture as follows:
python manage.py dumpdata --indent=3 >…

GChorn
- 1,267
- 1
- 19
- 36
7
votes
3 answers
model.save() not called when loading Django fixtures?
I am overriding my Django model save() method, so I can do some extra sanity checking on the object. (Is save() the correct place to do this?)
It doesn't appear that my fixtures/initial_fixtures.yaml objects have their save() method called. How can…

Joseph Turian
- 15,430
- 14
- 47
- 62
7
votes
1 answer
Do Django Fixtures load in incorrect order when testing?
I am testing my application and I am running into an issue and I'm not sure why. I'm loading fixtures for my tests and the fixtures have foreign keys that rely on each other. They must be loaded in a certain order or it won't work.
The fixtures I'm…

Aaron
- 4,206
- 3
- 24
- 28
6
votes
2 answers
What is the best way to continuously export information from a Scrapy crawler to a Django application database?
I am trying to build a Django app that functions sort of like a store. Items are scraped from around the internet, and update the Django project database continuously over time (say every few days). I am using the Scrapy framework to perform…

emish
- 2,813
- 5
- 28
- 34
6
votes
1 answer
django : loading fixtures with natural foreignkey fails with 'ValueError: invalid literal for int() with base 10'
My models are ...
class StateManager(models.Manager):
def get_by_natural_key(self, name):
return self.get(name=name)
class DistrictManager(models.Manager):
def get_by_natural_key(self, name, state):
return…

parijath
- 113
- 5
6
votes
2 answers
Automatically Load Django Fixture
I'm running Django 1.7. My file tree for the project is as such:
/project/app/fixtures/initial_data.json
/project/app/settings.py
I know I can run the python manage.py loaddata app/fixtures/initial_data.json command that will work for populating my…

Peter Graham
- 2,467
- 2
- 24
- 29
6
votes
2 answers
Django loaddata with Natural Keys not querying correct Foreign Key
Here is my problem. I am trying to load some data that has a natural key relationship to another model.
I modified the parent model to generate natural keys.
I exported the the data from the old database using the command:
manage.py dumpdata…

Alex
- 1,891
- 3
- 23
- 39
6
votes
1 answer
Fixtures in Django testing with South / Selenium
I am trying to run Selenium tests on a Django project (1.5.4), which uses South. I think South is conflicting with my tests when I try to inject initial data with fixtures, but I'm not sure why; I appreciate any help.
According to the Django…

user
- 4,651
- 5
- 32
- 60
5
votes
1 answer
How can I use pytest-django to create a user object only once per session?
First, I tired this:
@pytest.mark.django_db
@pytest.fixture(scope='session')
def created_user(django_db_blocker):
with django_db_blocker.unblock():
return CustomUser.objects.create_user("User", "UserPassword")
def…

superdee73
- 353
- 2
- 13
5
votes
2 answers
Are django fixtures a reliable database backup?
Django n00b here. I was wondering, are django fixtures a reliable way to backup my data, instead of actually backup up the database? What if my database is very large?
Thanks.

kevin_82
- 317
- 3
- 10
5
votes
4 answers
How to load Django fixtures from all apps?
I'm using fixtures in my Django application but only two apps are getting their fixtures loaded.
When I manually run loaddata with --verbosity=2 I can see that it only looks in two apps although I have more with fixtures directories created…

Franck
- 6,285
- 5
- 26
- 35
5
votes
0 answers
Migrating Wagtail data between environments
I'm trying to move data from our QA servers to production (or dev->local, qa->dev, etc.) with the Django dumpdata and loaddata commands.
I've successfully got things exported that have no foreign dependencies, like so:
python manage.py dumpdata…

Michael Volo
- 314
- 3
- 13
5
votes
2 answers
Django fixtures with specific data
I have an app with 3 models that refer to each other in a parent-child way:
class A(Model):
# ...
class B(Model):
a = ForeignKey(A)
# ...
class C(Model):
b = ForeignKey(B)
# ...
In my production database, I have hundreds…

physicalattraction
- 6,485
- 10
- 63
- 122
5
votes
2 answers
Django - testing using large tables of static data
I am using "manage.py test" along with a JSON fixture I created using using 'dumpdata'
My problem is that several of the tables in the fixture are very large (for example one containing the names of all cities in the US) which makes running a test…

Michael Bylstra
- 5,042
- 4
- 28
- 24
5
votes
1 answer
Update database records from data fixtures
How can I update an already populated Django database with records from a data fixture (or other serialized records)?
I know I can use Django data fixtures to provide initial data. Can I use the same already written features to update the database…

eugene
- 39,839
- 68
- 255
- 489