记住安全性。
#app/hashers.py
from django.contrib.auth.hashers import BasePasswordHasher
from django.utils.datastructures import SortedDict
class DummyPasswordHasher(BasePasswordHasher):
algorithm = "dummy"
def encode(self, password, salt):
return "dummy$%s" % (password)
def verify(self, password, encoded):
algorithm, hash = encoded.split('$', 2)
return hash == password
def safe_summary(self, encoded):
algorithm, hash = encoded.split('$', 2)
return SortedDict([
('algorithm', algorithm),
('password', hash),
])
#settings.py
PASSWORD_HASHERS = (
'app.hashers.DummyPasswordHasher',
)
PREFERRED_HASHER = 'app.hashers.DummyPasswordHasher'
编辑我已经纠正了拼写错误