[Django]-Django.db.utils.IntegrityError: insert or update on table "authtoken_token" violates foreign key constraint

3👍

For some reason in your db structure auth_user is still set as ForeignKey. As you are using Account as your user model, it should be something like account_user it might be some migration problem. My best guess is that you had a previous user model(default one may be) and in mid project you created/migrated your new user model (Account). There may be old data present in your db. If that’s the case, I think quickest solution would be to remove all the migration from Account app and migrate again (to let django create all the db from scratch)

note: of course this means, you have to delete all the current users.

0👍

WARNING! Migrate "zero" drop all tokens!

Works for me

./manage.py migrate authtoken zero

and then

./manage.py migrate authtoken

Leave a comment