0

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 hoping someone might explain to me what the REFERRED might mean. What kind of error am I looking for?

I made a few migrations and now the DB is out of wack. So the json is slightly off to the DB. There are multiple things called number though. Referred sounds it's some kind of foreignkey error!? Can you give me any hint what to look for?

JasonTS
  • 2,479
  • 4
  • 32
  • 48
  • REFERRED class in your model is not having a column called number. even if you have a column called number. and what command are you running for the migrations – Exprator May 04 '17 at 05:32

1 Answers1

0

I had a similar issue and found out what REFERRED was by adding print(query) in django/db/backends/sqlite3/base.py#L297. That showed me all the queries django was running against my sqlite3 database.

In my case, loaddata was not finding the field id (the primary key field that is default in django) for a model in which I had set primary_key=True to one of its fields. Eventhough django was not automatically generating the id field (correct behaviour), loaddata kept looking for the id field. A possible solution would be to add --natural-primary option, but that didn't work for me ATM.

Ref: https://docs.djangoproject.com/en/1.11/topics/serialization/#topics-serialization-natural-keys

Shadi
  • 9,742
  • 4
  • 43
  • 65