Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django - loaddata error when converting db from sqlite3 to postgres

I am trying to convert from a sqlite3 db to Postgres (so that I can have timezone-aware datetime fields with django 1.4). I dumped the data from the sqlite3 db. Then switched settings to point to the empty postgres db. Then ran syncdb, then south migrations. All good so far.

When I try to reload the dumped data into postgres, I get an error:

An exception occurred while loading data: duplicate key value violates unique constraint "django_content_type_app_label_model_key" DETAIL: Key (app_label, model)=(django_twilio, caller) already exists.

I removed twilio from the app and still got a similar error, just with the next object in the db.

Any help is appreciated. I'm new to programming and django. Thanks!

like image 221
mb52089 Avatar asked Apr 09 '12 19:04

mb52089


Video Answer


1 Answers

It is Django. I actually found the answer in an existing stackexchange post:

Switching Django project from sqlite3 backend to postgresql failes when loading datadump

I needed to TRUNCATE the database. Thank you for your help.

like image 94
mb52089 Avatar answered Oct 05 '22 02:10

mb52089