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
4
votes
3 answers

Django fixture loading very slow

I'm trying to provide initial data using 2 sets of fixtures. The first fixture format looks like this. { "pk": 1, "model": "data.Person", "fields": { "full": "Anna-Varney", "num": "I", "short": "Anna-Varney" } …
dl8
  • 1,270
  • 1
  • 14
  • 34
4
votes
2 answers

Install Django fixture from URL

I've got a few rather large fixtures of static data (about 20MB each) that I'd like to keep out of my repo to keep the repo size under control. Is there any way to load fixtures from a URL? I took a long shot and pushed my fixture up to S3 in hopes…
Jason
  • 2,259
  • 2
  • 17
  • 12
3
votes
1 answer

How can I load all fixtures inside particular directory while writing TestCases in Django using Pytest

I have multiple fixtures(json files) inside admin folder and I need to load all the fixtures of that directory without manually writing all fixture's locations. I have tried the below code but it's not working @pytest.fixture(scope='session') def…
Hetvi
  • 188
  • 6
3
votes
1 answer

What is the format for a PointField in a django fixture?

Suppose I have the following django model: from django.db import models from django.contrib.gis.db import models class Location(models.Model): name = models.CharField(max_length=200) point = models.PointField() And I want to load the…
User
  • 62,498
  • 72
  • 186
  • 247
3
votes
1 answer

How to create fixture where there is relation between two tables in Symfony?

I have two entities say 'User' and 'Address' in which I have 'OneToOne' relation between them. User table has a column 'address_id' which is Foreign key, stores the id of Address table. I have tried to create fixture by using 2 different…
Saurabh
  • 432
  • 1
  • 10
  • 23
3
votes
2 answers

DJANGO 1.11 - Can't find fixtures

Problem I was trying to use fixtures to populate my database, so I started by reading through the documentation for loaddata and by default, it looks in the fixtures directory inside each app for fixtures. My problem is that when I run python…
Tiago Martins
  • 165
  • 1
  • 1
  • 11
3
votes
1 answer

manage.py datadump of a large database in Django 1.1 (creating testdatabase)

To be able to do some decent unittests I want to create a testdatabase. After reading the Django docs, I came to the conclusion that the best way to do this is by creating a testdatabase from the actual database, with the use of fixtures. To create…
markijbema
  • 3,985
  • 20
  • 32
3
votes
1 answer

How to add relationships in Django fixtures by explicitly adding object's fields?

I'm working with Django Framework. I have two models: Component and ComponentProperty. class Component(models.Model): name = models.CharField(unique=True, max_length=255) component_properties =…
3
votes
1 answer

Can Django Syncdb handle compressed initial_data.json.tgz fixtures?

Need to keep the size of the package down, so is it possible to compress the initial data in some supported format for syncdb to pickup?
Val Neekman
  • 17,692
  • 14
  • 63
  • 66
3
votes
1 answer

How to get django to upload an image file via fixtures

I have a class in my models.py: class Car(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4) create_date = models.DateTimeField('date added', auto_now_add=True) modify_date = models.DateTimeField('date modified',…
Tom
  • 2,545
  • 5
  • 31
  • 71
3
votes
1 answer

How to reference ContentType in Django's fixture?

I'm writing tests for Django project with django-guardian. Fixture for permissions look like: - fields: content_type: 10 object_pk: '2' permission: 22 user: 1 model: guardian.userobjectpermission pk: 1 Is it safe to reference…
Domen Blenkuš
  • 2,182
  • 1
  • 21
  • 29
3
votes
1 answer

Natural-key serialize Django model with one-to-one field as primary key

I have a Recipe model and Label model referring to the former with a OneToOneField. I put managers and natural_key methods to export both models with JSON encoding. class RecipeManager(models.Manager): def get_by_natural_key(self, name): …
steppo
  • 583
  • 3
  • 20
3
votes
1 answer

Hook to perform actions after loaddata command (loading fixtures)

There's post_syncdb signal to perform actions that can be done after syncdb. Is there a similar hook to perform some actions after loading fixtures i.e. after python manage.py loaddata command ? I have a script that creates a new database, runs…
user
  • 17,781
  • 20
  • 98
  • 124
3
votes
1 answer

Django testing error installing fixture- no such table

Strange error after running "python manage.py test" django.db.utils.OperationalError: Problem installing fixture '/home/voxa/django/test_test/resume/fixtures/initial_data.json': Could not load resume.Person(pk=1): no such table: resume_person But…
Crampus
  • 491
  • 1
  • 8
  • 16
3
votes
1 answer

"String or unicode input unrecognized as WKT EWKT, and HEXEWKB"

I am trying to load a dumped geodjango fixture into postgis. The fixture loads perfectly into other computers with the same setup, but on my setup I get: ValueError: Problem installing fixture 'C:\....json': String or unicode input unrecognized as…
Udi
  • 29,222
  • 9
  • 96
  • 129