[Answered ]-How to fix errors for Django's Auth/CustomUser after resetting the migrations and db?

1👍

first of all u need to delete all your migrations files(sure u have ) and the (pycache) …

After you have done that dont just run makemigration u have to be logical with it

  1. run python manage.py makemigrations <app_name:the app that contains the AUTH_USER_MODEL>
  2. run python manage.py makemigrations <app_name> but this time u decide what app comes next in the way u wrote ur models they makemigrations in that order’
    3)run python manage.py makemigrations
    4)lastly run python manage.py migrations

… this how i solved this issue anytime i run into this problems

0👍

Obviously messing with the CustomUser model in Django isn’t to be attempted casually, but this was a good learning experience. So for the newly initiated accidentally stuck at the same spot, the answer by Ogechuwku Matthew is a good start.

To elaborate-this is what I did:

  1. Deleted all the migration files, including files in __pycache__ (EXCEPT for the __init__ file(s).
  2. Disabled the AUTH_USER_MODEL = 'myapp.MyCustomUser' line in settings.py This step is key.
  3. Removed (or commented out) all but the most essential files.
  4. Commented out all but the CustomUser model and models extended from it.
  5. Ran python manage.py makemigrations <app_name> and then ‘python manage.py migrate`
  6. After step 4 worked, ran python manage.py makemigrations <app_name> and python manage.py migrate again.
  7. Moved the rest of the files back in, starting with the simplest bits, like ‘HomeView’ in views.py and ‘home.html’.
  8. When the app started up with ‘home.html’, un-commented models, views, and urls one cluster at a time.

Additionally: If error occur when running the app, first check the embedded dynamic links–they may extend or include files that aren’t there yet-same with {% load static %}

👤YCode

Leave a comment