WebFaction
Community site: login faq

I'm having a problem when trying to add objects to my database in my app. I just deployed this app and it's working on my local installation, where I'm using sqlite. On my webfaction deployment, I'm using postgre.

I get the following error:

IntegrityError at /app/project/
insert or update on table "app_project" violates foreign key constraint "app_project_owner_id_fkey"
DETAIL:  Key (owner_id)=(1) is not present in table "app_user".
Request Method: POST
Request URL:    http://username.webfactional.com/app/project/
Django Version: 1.2.3
Exception Type: IntegrityError
Exception Value:    
insert or update on table "app_project" violates foreign key constraint "app_project_owner_id_fkey"
DETAIL:  Key (owner_id)=(1) is not present in table "app_user"

It seems that I have not been able to create the database properly. I'm able to add users in my admin and register new users from my django app, but I keep getting this "foreign key constraint" error when trying to add other objects that require users as a foreign key. In the phpPgAdmin, there are no rows in flow_user, so apparently it's not correctly creating the users? I'm using south for migrations which might have created an error?

Is there something I might need to do change in my models to get my django app working in postgre after using sqlite?

Any ideas how to correct this error, recreate the database or why this error has arised?

asked 05 Jan '11, 05:42

Rrr8
16124
accept rate: 0%


The error basically says that there is data missing from your database. The most straightforward way to deal with this would be to dump the data from your old application (using the "manage.py dumpdata"), and then load the data to your new application (using "manage.py loaddata"). You can learn more about the dumpdata/loaddata commands at: http://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-appname-appname-appname-model

permanent link

answered 05 Jan '11, 06:07

tie
1.4k13
accept rate: 44%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×109
×32

question asked: 05 Jan '11, 05:42

question was seen: 11,777 times

last updated: 05 Jan '11, 06:07

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM