python - django integrity error, i know why, but dont know how to solve -


i changed former user model inherits django's user model.

from django.contrib.auth.models import user  class userprofile(user):  #fields.. 

but other models pointing former model , if want migrate, getting error:

(user_id)=(9) not exist in auth_user table.  

reasonable error message. should now? stuck. using django version 1.4

i made screenshot of error:

enter image description here

you don't version of django you're using; if you're using 1.5, need set auth_user_model setting tell django use (see auth docs more info). if you're on earlier version, don't want subclass user model @ all, create profile (like class name indicates) separate model , link foreignkey (see old profile docs more on that).

did change name of model when added parent class? want set name of table in userprofile matches old name. django model docs:

to save time, django automatically derives name of database table name of model class , app contains it. model’s database table name constructed joining model’s “app label” – name used in manage.py startapp – model’s class name, underscore between them.

for example, if have app bookstore (as created manage.py startapp bookstore), model defined class book have database table named bookstore_book.

to override database table name, use db_table parameter in class meta.

so trick:

class userprofile(user):     # other stuff     class meta:         db_table = "myapp_user" 

hope helps!


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -