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
2
votes
1 answer
loaddata command deserializes fixture with a future model state
So... Here is the issue I ran into:
My Django project was broken : I landed on the default homepage saying start project and manage.py runserver [::]:8000 said run migrate.
All my migrations were applied (the database was in the right state) so I…

Nicolas W.
- 642
- 6
- 20
2
votes
2 answers
FieldDoesNotExist on loading Fixture
I'm trying to load a fixture called initial_data.json:
[{"pk": 1, "model": "contenttypes.contenttype", "fields": {"model": "logentry", "name": "log entry", "app_label": "admin"}}, {"pk": 2, "model": "contenttypes.contenttype", "fields": {"model":…

Sinha
- 773
- 2
- 16
- 34
2
votes
1 answer
Understanding Django initial_data fixture
Question
Why does Django automatically load the initial_data.json fixture when it's located inside the project directory but not located in one of the three specified locations that Django searches for fixtures?
Configuration Information
I have…

Matthew Rankin
- 457,139
- 39
- 126
- 163
2
votes
2 answers
Django : ValueError on loading fixture
Im trying to load a fixture which looks like this :
some_filename.json
[
{
"fields": {
"blockName": "Home & Tech",
"catName": "Home",
"catUrl": "http://www.buyam.com.ng/catalog/home/35",
"prodDesc": "Jojo Pet…

mohit
- 83
- 1
- 6
2
votes
1 answer
Django fixtures and AttributeError: 'QuerySet' object has no attribute
I am seeing this error with a simple integration test. The django app is called storageadmin with a model called Disk with a custom model method called pool_name. I am using South and django rest framework and have SOUTH_TESTS_MIGRATE = False in…

user3247093
- 23
- 1
- 5
2
votes
0 answers
django dumping yaml utf8 fixture to postgresql
I have the following fixture:
- model: backoffice.Language
pk: 1
fields:
name: Français
code: fr
- model: backoffice.Language
pk: 2
fields:
name: English
code: en
- model: backoffice.Language
pk: 3
fields:
name:…

user2346536
- 1,464
- 2
- 21
- 43
2
votes
1 answer
Django tests - fixture User matching query does not exist
I'm trying to run a test that loads a fixture. One the models has GenericForeign key to ContentType and a Foreign key to auth.Users. It associates users with content they create. I created fixture with --natural key (as per below) and can foreign…

user3138929
- 369
- 5
- 18
2
votes
1 answer
can I run django test but with out model define?
my problem is that. this is a old django project that I need to work on it.
As unknown reason, the project don't use django model. Instead, it define some class to CRUD the database by pure sql. and the project has no tests at all.
now, I want to…

hackrole
- 121
- 8
2
votes
0 answers
Django fixtures - linking two models with OneToMany
I am pre-populating my Django app with two tables and using csvimport, which is great. The two models have a OneToMany relationship; each Testresult is related to a single School. There are multiple Testresults per School.
The two models have the…

wsvincent
- 207
- 4
- 13
2
votes
1 answer
Django fixtures, loading in large amounts of data
So I have two 200mb JSON files. The first one takes 1.5 hours to load, and the second which (which makes a bunch of many-to-many relationships models with the first), takes 24+ hours (since there's no updates via the console, I have no clue if it…

dl8
- 1,270
- 1
- 14
- 34
2
votes
1 answer
django-dynamic-fixture foreign key to self
I have a tests.py that looks like this:
from django_dynamic_fixture import G,N
from person.models import Person
from django.test import TestCase
class EmailSendTests(TestCase):
def test_send_email(self):
person = N(Person)
My Person…

Trewq
- 3,187
- 6
- 32
- 50
2
votes
1 answer
Unit testing in Django: How to initialize database
I am trying to do Test Driven Development with Django. My problem is that I need to add some things in the database before running the tests, for instance a number of users, departments and their permissions. I tried to do that using fixtures but I…

Serafeim
- 14,962
- 14
- 91
- 133
2
votes
2 answers
Django fixtures for model from imported application (like django-allauth)
I know that is possible to create fixtures file like initial_data.json for my own model. I want to create similar file for tables which are created and used by imported django-allauth application.
I tried:
[
{
…

noisy
- 6,495
- 10
- 50
- 92
2
votes
3 answers
Loading Fixtures Django
I'm trying to load some fixtures within my Django tests, but they don't seem to load.
In my settings.py, I specify:
FIXTURE_DIRS = (os.path.join(PROJECT_DIR, 'dhtmlScheduler\\fixtures\\'))
Now, within my test case:
def setUp(self):
fixtures =…

james_dean
- 1,477
- 6
- 26
- 37
2
votes
2 answers
django doesn't load initial fixtures while syncdb
I've got a django project with following structure:
/djninja # project dir
/djninja # main app dir
/bands # app dir
/fans # app dir
/lyrics # app dir
I've created a initial_data.yaml file to make syncdb load fixtures (I prefer YAML format).…

ducin
- 25,621
- 41
- 157
- 256