Django IntegrityError: Foreign key constraint violation on token_blacklist_outstandingtoken
I'm encountering an IntegrityError
when trying to log in to my Django application. The error suggests a foreign key constraint violation. Here are the details:
## Error Message
django.db.utils.IntegrityError: insert or update on table "token_blacklist_outstandingtoken" violates foreign key constraint "token_blacklist_outs_user_id_83bc629a_fk_auth_user"
DETAIL: Key (user_id)=(5
) is not present in table "auth_user".
Context
- This error occurs when a user attempts to log in.
- The POST request to
/auth/login/
returns a 500 status code. - Date and time of the error: [07/Sep/2024 11:08:11]
Relevant Code
[Include any relevant code snippets here, such as your login view or authentication configuration]
Question
- What could be causing this foreign key constraint violation?
- How can I resolve this issue and allow users to log in successfully?
Any insights or suggestions would be greatly appreciated. Thank you!