Code Implementation
Create a project by the following command:
django-admin startproject ProductStore
cd ProductStore
Update AUTH_PASSWORD_VALIDATORS
Go to the settings.py and find the following code, Here, we set the minimum length of the password should be 11 characters.
Python3
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.MinimumLengthValidator' , 'OPTIONS' : { 'min_length' : 11 , # Change this to your desired minimum length } }, { 'NAME' : 'django.contrib.auth.password_validation.NumericPasswordValidator' , }, ] |
Create superuser
Creating a superuser in Django is essential for administrative tasks and accessing the Django admin interface, allowing full control over the application’s database and content management.
python manage.py createsuperuser
Migrate your Data to the Database
Migrating data to the database in Django is essential to ensure that your application’s data schema aligns with the defined models, enabling proper data storage, retrieval, and consistency.
python manage.py makemigrations
python manage.py migrate
Deploy Django Project
Deploy the Project using the following command
python manage.py runserver
Now go to following Django admin pannel, and login with username and password.
http://127.0.0.1:8000/admin/
Go to add user and create new user, if you enter password less than 11 character you will get an error as shown below:
What is the Minimum Length of Password in Django?
In Django, the default minimum period for passwords is 8 characters. This method that while you create a personal account or alternate a password, Django enforces a minimal password period of eight characters by default. However, you could customize this minimum length by enhancing your mission’s settings.
In Django, you could set the minimum duration of a password by configuring the AUTH_PASSWORD_VALIDATORS putting to your venture’s settings file (generally settings.Py). Django lets you define a listing of password validators that put into effect various password regulations, consisting of minimal duration necessities.
Contact Us