Django 密码生成器 [英] Django Password Generator

查看:16
本文介绍了Django 密码生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将一堆用户及其数据导入 django 项目.我需要为每个人分配一个密码.是否有这样一个用于生成密码的片段来处理 Django 哈希和盐?

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?

推荐答案

也可以使用内置函数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

这篇关于Django 密码生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆