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
- run python manage.py makemigrations <app_name:the app that contains the AUTH_USER_MODEL>
- 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:
- Deleted all the migration files, including files in
__pycache__
(EXCEPT for the__init__
file(s). - Disabled the
AUTH_USER_MODEL = 'myapp.MyCustomUser'
line insettings.py
This step is key. - Removed (or commented out) all but the most essential files.
- Commented out all but the
CustomUser
model and models extended from it. - Ran
python manage.py makemigrations <app_name>
and then ‘python manage.py migrate` - After step 4 worked, ran
python manage.py makemigrations <app_name>
andpython manage.py migrate
again. - Moved the rest of the files back in, starting with the simplest bits, like ‘HomeView’ in
views.py
and ‘home.html’. - 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 %}
Source:stackexchange.com