Questions tagged [django-fixtures]

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.

187 questions
2
votes
2 answers

Django is ignoring my TestCase fixtures

I've got Django 1.4. In my test.py, I've got the requisite TestCase import: from django.test import TestCase To isolate the issue, I've added the line: fixtures = ['westeros'] to the default example test case, i.e. class SimpleTest(TestCase): …
Ghopper21
  • 10,287
  • 10
  • 63
  • 92
2
votes
1 answer

How best to initialize one-time-only Django objects which can't be fixtures?

I am writing an app in Django which has a few sitewide fixed objects I need to instantiate which, for one reason or another, can't be fixtures. For example, some (e.g. Permissions) I can't hardcode a PK for because I can't be sure that they'll be…
Eric P
  • 4,587
  • 6
  • 24
  • 19
1
vote
1 answer

Proper way to manage fixtures in django

today I had a discussion with my colleguaes about how we should manage fixtures in our django application. We cound not find any solution that would satisfy everyone, so I'm asking this question here. Suppose we have quite big django project with…
dragoon
  • 5,601
  • 5
  • 37
  • 55
1
vote
2 answers

Unable to load fixture for through model django

What I am trying to do? I have created a fixture for a through model and now I want to load it in my database. What is the problem? While loading the fixture using Django loaddata command for through model I get this…
Ahtisham
  • 9,170
  • 4
  • 43
  • 57
1
vote
1 answer

Django dumpdata-loaddata error serializing custom class: ' Syntax error near "F" '

I'm trying to create a set of fixtures from my database using the dumpdata command provided by Django. I want to be able to load these fixtures using the loaddata command. One of the Models I'm trying to dump has a custom field: particularly, I'm…
jorgmo02
  • 41
  • 7
1
vote
0 answers

Can Django fixtures be used for production?

I have a Django application that reads different CSV files and saves them to the same model/table in the DB. While fixtures are certainly used for setting up a test environment quickly, I used the fixture to configure the different CSV Schemata that…
Debanjan Basu
  • 834
  • 1
  • 8
  • 29
1
vote
1 answer

How to return multiple value from a pytest fixture with scope = session

I have created pytest fixture in conftest.py for creating user and auto login @pytest.fixture(scope="session") def api_client(): from rest_framework.test import APIClient return…
1
vote
1 answer

Trying to follow django docs to create serialized json

Trying to seed a database in django app. I have a csv file that I converted to json and now I need to reformat it to match the django serialization required format found here This is what the json format needs to look like to be acceptable to django…
Justin Benfit
  • 423
  • 3
  • 11
1
vote
0 answers

Populate Data in Database Using YAML File through Fixtures in Django

I'm trying to populate the data in the database for the Employee Model Also, I'm not going to use Foreign Key ID's as given below Example 1: - model: employee.employee pk: 1 fields: user: 1 manager: NULL department: 1 …
1
vote
1 answer

DeserializationError when adding fixture on server (loaddata)

I am trying to add my data to database in my server. I use exactly the same JSON file in my local machine and it works. But when I do the same in server it gives me Deserialization Error. The JSON file is so big that I can't show it here but I am…
Ulvi
  • 965
  • 12
  • 31
1
vote
1 answer

(Django) Problem installing fixture 'rules.json': 'NoneType' object has no attribute 'id'

I'm trying to populate my db with fixtures with the next command: python .\manage.py loaddata .\rules\fixtures\rules.json But I get the next error: AttributeError: Problem installing fixture 'C:\Users\Ángel…
AngelQuesada
  • 387
  • 4
  • 19
1
vote
1 answer

Django: OnetoOne relations using fixtures and uuids

I have a model called user, and another one called patient as follow: class Patient(Model): user = OneToOneField('users.User', on_delete=CASCADE, related_name="patient", blank=True, null=True) class User(Model): id…
Alvaro
  • 1,430
  • 2
  • 23
  • 41
1
vote
0 answers

Cannot Load Dhango Fixtures into database

I am able to load 1 fixture file into the database, but not the 2nd file. I run the command python manage.py loaddata fixture.json, and I get the error. I'm not sure how to solve this serialization error, any insights appreciated. The error: …
Amir
  • 1,422
  • 1
  • 15
  • 28
1
vote
0 answers

django.db.utils.IntegrityError: Problem installing fixture

I'm attempting to create a fixture from my development database data and storing it my test database. This data happens to be only one model. I ran the dumpdata command as such: python manage.py dumpdata minerals.mineral --all --indent=4…
binny
  • 649
  • 1
  • 8
  • 22
1
vote
0 answers

Django test resolves by for loop

I am doing some test in Django. I use fixtures to pre load some data and test API POST. In my POST, I want to link some data by foreign key. The test behavior is odd. I need to place a for loop in order for it to succeed. Here's my example for my…