python - 如何加密django中的密码字段

标签 python django encryption passwords

我有一个带有名称、代码和密码的模型。我需要加密密码。另外,我不应该在密码字段中显示纯文本。 我提到了这个链接

Password field in Django model

但答案是旧的,需要知道现在的方法是什么。

我的模型如下

class Crew(models.Model):
    crew_id = models.AutoField(primary_key=True)
    crew_code = models.CharField(max_length=200, null=False, unique=True)
    crew_name = models.CharField(max_length=200, null=False)
    crew_password = models.CharField(max_length=200, null=False)

最佳答案

在你看来

from django.contrib.auth.hashers import make_password
crew_password = 'take the input if you are using form'
form = FormName(commit=False)
form.crew_password=make_password(crew_password)
form.save()

关于python - 如何加密django中的密码字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44450520/

相关文章:

security - 在 Windows 上使用 SQLCipher 编译 SQLite

Python 错误 :only integers, 切片 (`:` )、省略号 (`...` )、numpy.newaxis (`None` ) 和整数或 bool 数组是有效索引

python - 如何获得 280slides.com 功能?

Python 字典用于配对并使用字典检查反对称性

Django 1.9 : enabling ssl

django - 如何查询django中的隐式直通表(ManyToMany字段)?

python - 具有 'internal'/'external' 守护线程的应用程序之间的功能差异

Django AssertionError "sensitive_post_parameters didn' t 在管理中添加用户时收到 HttpRequest

javascript - filereader生成的图像是否缓存在浏览器中?

java - 读取 RSA OpenSSH 格式的 KeyPair 的公钥?