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
0
votes
1 answer

django deserialization error while generating fixtures

I have generated test data from a tool called Mockaroo. I have used csv2json.py script to convert the csv downloaded from Mockaroo to json format. The json generated is being used as a fixture data to run unit tests. I am facing deserializaion error…
Anitha
  • 38
  • 7
0
votes
0 answers

Fixtures - Working with many to many intermediary models

I am training myself on Django and working on a movie blog and have issues with my fixtures that I scrape from themoviedb's api. I am wondering the right way to insert a ManyToMany with intermediary model. Here is my current state (removing the…
Louis L
  • 1
  • 1
0
votes
1 answer

Load/dump fixture from/to json string in django unittest

I have a custom model in django with overriden to_python() and get_db_prep_save() methods. I discovered a bug: when dumping and reloading data it was inconsistent. The bug is fixed but I want to unittest it with simple json string. My question is:…
makozaki
  • 3,772
  • 4
  • 23
  • 47
0
votes
1 answer

Can I load a fixture with the DateField set to null?

I'm have some Datefields I would like to keep null or blank when I load a fixture. Is there a way to keep them null or blank without putting some default value? In the model, I have already set null=True, blank=True.
H C
  • 1,138
  • 4
  • 21
  • 39
0
votes
1 answer

In django, is it a bad practice to retrieve database records with slug fields loaded by fixtures?

I am working on a code base where the original developer created a ProductType model with several rows in the database representing a few product types. Throughout the code, there are statements like ProductType.objects.get(slug='foo_product_type').…
rmbIV
  • 1
  • 2
0
votes
1 answer

populate table with initial data

I want to prepopulate some tables with initial data and also modify certian fields. Im currently doing this by writing custom management commands and populating database using python manage.py . Recently i read about fixtures and came to know its…
Mohit Harshan
  • 1,916
  • 1
  • 18
  • 41
0
votes
1 answer

create fixtures with custom manager methods, json dumps and ways to avoid type error :xxx is not json serializable

I'm trying to create a test fixture using custom manager methods as my app uses a subset of dbtables and fewer records. so i dropped the idea of using initial_data. In manager I'm doing something like this. in Managers.py: sitedict =…
stackover
  • 6,275
  • 6
  • 22
  • 20
0
votes
0 answers

pyyaml datetime.now() + timedelta

I want to create fixtures in Django project. We are using fixtures to populate DB with test data. For some models.fields I need to set fresh date. For example: from dateutil.relativedelta import relativedelta from datetime import…
Vadim Zabolotniy
  • 347
  • 5
  • 16
0
votes
1 answer

Standard way to load initial (and ongoing) data into Django

Suppose I have a model with a field that restricts another model. For example, a Thing whose name has to be in the current set of AllowedThingNames. The set of allowed_thing_names changes (infrequently) by an external source. I have code to get…
trubliphone
  • 4,132
  • 3
  • 42
  • 66
0
votes
1 answer

Django fixtures many to many with natural keys over multiple fields

I'm writing some additional fixtures for a project, and I have a question about how to use the natural keys. In another fixture, the natural key for area is defined like so: "fields": { "area": [ "auckland", …
Darkstarone
  • 4,590
  • 8
  • 37
  • 74
0
votes
0 answers

installation fixture django-municipios

I am getting the following error when executing the command python manage.py loaddata municipios_geo_2013_4674.json.bz2 or python manage.py loaddata municipios_geo_2013_4674.json. How to solve the AttributeError? Package and json in:…
LSM
  • 330
  • 2
  • 13
0
votes
1 answer

Fixture not loading in Django

Settings.py: import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) FIXTURE_DIRS = ( os.path.join(BASE_DIR,…
RubyNoob
  • 517
  • 1
  • 7
  • 17
0
votes
1 answer

Can't login to django admin with superuser loaded via fixtures

I added superuser via fixtures: python manage.py loaddata data.json Here my data.json: [ { "pk": 1, "model": "auth.user", "fields": { "username": "admin", "first_name": "admin", …
0
votes
1 answer

what is no such column: REFERRED.number?

I'm trying to load a fixture and it gives me: django.db.utils.OperationalError: Problem installing fixtures: no such column: REFERRED.number Unfortunately, I cannot show the json, because there is all kind of private stuff in there, but I was…
JasonTS
  • 2,479
  • 4
  • 32
  • 48
0
votes
2 answers

How to recognize that Django fixtures loading is ongoing?

I have delusions that I've seen it in some piece of code and it's some variable's state. Example usage would be in signal handlers.
trybik
  • 482
  • 6
  • 16