Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

nothing happens after running python manage.py shell < script.py

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 script.py 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 manage.py shell < script.py

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My script.py 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)
        user.save()

>Solution :

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

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading