nothing happens after running python shell <

This is my first time trying to run a script. I’m trying to hash previously stored plain text in my db.

Anyway I created file in my project folder it doesn’t seem to do anything what am I missing?

The command I’m running in my virtual env:
python shell <

My file:

from django.contrib.auth.hashers import make_password
from myapp.models import User

def hash_existing_passwords():
    for user in User.objects.all():
        user.user_password = make_password(user.user_password)

>Solution :

As already explained by Sir @SunderamDubey in the above comment:

Try adding the line hash_existing_passwords() at the end of, this will execute the function when you run the python shell < command.

Leave a Reply