Reputation: 461
I am trying to migrate a MySQL-based Django project to PostgreSQL. Unfortunately, all sql/syncdb commands fail as soon as I switch the database backend in settings.py.
python manage.py sql profile
w/ MySQL:
BEGIN;
CREATE TABLE `profile_department` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(100) NOT NULL UNIQUE,
[...]
python manage.py sql profile
w/ PostgreSQL (psycopg2):
DatabaseError: relation "profile_department" does not exist
LINE 1: ...nt"."homepage", "profile_department"."gd_id" FROM "profile_d...
^
Why does Django behave differently with the two DB backends?
Upvotes: 0
Views: 288
Reputation: 461
Thomas was right, there were indeed two queries buried somewhere in models.py that referred to the Department class:
ROOT_DEPARTMENT = Department.objects.get(pk=14)
FACULTIES = Department.objects.filter(parent=ROOT_DEPARTMENT)
Thanks!
Upvotes: 1