简体   繁体   English

"Django 中的超级用户转储数据\/加载数据"

[英]Superuser dumpdata/loaddata in Django

I'm having a trouble on how can I dump a encrypted password data into authuser table in django, Currently I'm using python manage.py loaddata fixtures.json<\/code> to dumpdata into database it works fine but the password is not encrypted, how can I encrypt it when using loaddata?.我在如何将加密的密码数据转储到 django 中的 authuser 表时遇到问题,目前我正在使用python manage.py loaddata fixtures.json<\/code>将数据转储到数据库中它工作正常但密码未加密,怎么能我在使用 loaddata 时对其进行了加密? Is there any expert can share solutions or ideas with this problem, Much appreciate!有没有高手可以分享一下这个问题的解决方案或想法,不胜感激! 在此处输入图像描述<\/a>

   [{"model":"auth.user",
    "pk" : 2,
    "fields" : {"password" : "superadmin",
    "is_superuser" : "1",
    "username" : "superadmin",
    "first_name" : "name" ,
    "last_name" : "lname" ,
    "email" : "a@gmail.com" ,
    "is_staff" : "1",
    "is_active" : "1"
   }]

Django don't store the raw password in the database. Django 不会将原始密码存储在数据库中。 It just store the encrypt one in a column called password<\/code> .它只是将加密的内容存储在名为password<\/code>的列中。 When you create a password for your user in this way, you are populating this column with raw data.当您以这种方式为您的用户创建密码时,您将使用原始数据填充此列。 The "superadmin" is the encrypted password. “superadmin”是加密的密码。

Try to use it to login, you notice it doesn't work, because "superadmin" isn't the password, it's just their value encrypted.尝试使用它登录,您会发现它不起作用,因为“superadmin”不是密码,它只是他们的加密值。

There are several alternatives, although honestly I don't like any of them: https:\/\/stackoverflow.com\/a\/34322435\/10712525<\/a>有几种选择,虽然老实说我不喜欢其中任何一种: https<\/a> :\/\/stackoverflow.com\/a\/34322435\/10712525

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM