I have imported a heap of users and their data to a django project. I need to assign a password to each. Is the such a snippet out there for password generation that will cope with the Django hash and salt?
Django provides a flexible password storage system and uses PBKDF2 by default.
@anotheruser Yes, you can't 'decrypt' a hashed password through django. (A hash is a one-way function not really encryption). You could possibly save the password of the user in plaintext in the DB, when they create a user account.
You can also use the built in function make_random_password
for user in new_users: password = User.objects.make_random_password() user.set_password(password) user.save(update_fields=['password']) # email/print password
Also you can use from django.utils.crypto import get_random_string
out of auth
module, it accepts keyword arguments length
and allowed_chars
as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With