dragon-fire-fly / developer_matcher

2 stars 1 forks source link

[BUG] IntegrityError #15

Closed dragon-fire-fly closed 1 year ago

dragon-fire-fly commented 1 year ago

Describe the bug The below error message was seen in the terminal when trying to create/update/delete a user in the admin panel:

The above exception (insert or update on table "django_admin_log" violates foreign key constraint "django_admin_log_user_id_c564eba6_fk_auth_user_id" DETAIL: Key (user_id)=(1) is not present in table "auth_user". ) was the direct cause of the following exception:

To Reproduce Steps to reproduce the behavior:

  1. Go to http://127.0.0.1:8000/admin/app_home/
  2. Click on 'add new user'
  3. Fill in required details to create new user and click "save"
  4. See error

Expected behavior A new user should be created with the credentials entered on the previous screen

Screenshots IntegrityError_django_admin_log

Desktop (please complete the following information):

dragon-fire-fly commented 1 year ago

This was caused by incorrect order of operations when migrating the database/creating the first user. This was solved by running python manage.py migrate admin zero followed by python manage.py migrate. migrate_admin_zero admin_migrate

This was solved with reference to this Stack Overflow article.