309👍
Add the following to settings.py
:
AUTH_USER_MODEL = "users_management.UserManage"
More generally,
AUTH_USER_MODEL = 'YourAppName.YourClassName'
- YourAppName: This is the name of the app that will have the User Model
- YourClassName: This is the name of the class used inside the models.py file
31👍
Add this in the settings :
AUTH_USER_MODEL = 'APPNAME.User'
This way we are telling Django to use our custom model instead the default one.
https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#substituting-a-custom-user-model
- [Django]-How can I check the size of a collection within a Django template?
- [Django]-How to pass django rest framework response to html?
- [Django]-How do you configure Django to send mail through Postfix?
12👍
The solution is to first add the following line into your settings.py-
AUTH_USER_MODEL="myproject.User"
Where myproject is your project name.
If you again get error then run following commands in your main directory-
python manage.py makemigrations
python manage.py migrate
This worked for me
- [Django]-No module named pkg_resources
- [Django]-How can I activate the unaccent extension on an already existing model
- [Django]-ImportError: No module named 'django.core.urlresolvers'
- [Django]-Timestamp fields in django
- [Django]-Django datetime issues (default=datetime.now())
- [Django]-Django: Error: You don't have permission to access that port
- [Django]-CORS error while consuming calling REST API with React
- [Django]-Pylint "unresolved import" error in Visual Studio Code
- [Django]-What is the purpose of adding to INSTALLED_APPS in Django?
2👍
Just add AUTH_USER_MODEL="your app name.User"
in settings.py
as shown in the code below
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTH_USER_MODEL="myproject.User"
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
- [Django]-Django + Ajax
- [Django]-How do Django models work?
- [Django]-How to override and extend basic Django admin templates?
0👍
If above steps don´t work, delete all migrations history and your database.
Then "makemigrations" and "migrate" like it was for the first time.
The User model must be created at beginning of the project, before firts migration.
- [Django]-Django proxy model and ForeignKey
- [Django]-PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django
- [Django]-Can't connect to local MySQL server through socket '/tmp/mysql.sock