So I have two databases, my development (default) database and my live database.
My model looks like so:
class Derp(models.Model):
company = models.ForeignKey(Co)
The rest of the model isn’t really relevant.
The problem is, when I go to save a new “Derp”, if you’ll allow the silliness, I get an “Integrity Error” because the ID I am referencing as my foreign key exists in my live database but not my default database.
To make matters a little more difficult, since this is a development, the table I am saving to is in my development database. So therefore the foreign key must be referencing the table in the development (and therefore throwing the error), but I need to get it to reference my live database.
Help please!
You really shouldn’t be using Django’s multiple database feature to distinguish between development and production databases.
When running in development, you should only have access to the dev db, and in production, just the production one. There should be no possibility of confusion.