[Fixed]-Django 1.9 createsuperuser bypass the password validation checking

11👍

You can change the AUTH_PASSWORD_VALIDATORS setting in in your dev environment. See the docs: https://docs.djangoproject.com/en/stable/topics/auth/passwords/#s-enabling-password-validation.

It is pretty straightforward: you will recognize the validators that caused your warning messages.

13👍

After creating the superuser with a complex password, you can set it to something easier in the shell (./manage.py shell):

from django.contrib.auth.models import User
user = User.objects.get(username='your_user')
user.set_password('simple')
user.save()
👤mimo

4👍

In fact, you do not need to modify the validator settings or first create a complex password and then later change it. Instead you can create a simple password directly bypassing all password validators.

Open the django shell

python manage.py shell

Type:

from django.contrib.auth.models import User

Hit enter and then type (e.g. to use a password consisting only of the letter ‘a’):

User.objects.create_superuser('someusername', 'something@example.com', 'a')

Hit enter again and you’re done.

👤User

0👍

mimo‘s answer is correct but don’t works if you don’t using default User model

According mimo‘s answer and this article, I changed script to this one

from django.contrib.auth import get_user_model
User = get_user_model()
user = User.objects.get(email='user@mail.com')
# or user = User.objects.get(username='your_user')
user.set_password('simple')
user.save()
👤rzlvmp

Leave a comment