本文整理汇总了Python中django.contrib.auth.forms.ReadOnlyPasswordHashField类的典型用法代码示例。如果您正苦于以下问题:Python ReadOnlyPasswordHashField类的具体用法?Python ReadOnlyPasswordHashField怎么用?Python ReadOnlyPasswordHashField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReadOnlyPasswordHashField类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
def render(self, name, value, attrs):
original = ReadOnlyPasswordHashField.widget().render(name, value, attrs)
if 'Invalid' not in original:
return original
encoded = value
if not encoded:
summary = mark_safe("<strong>%s</strong>" % _("No password set."))
else:
size = len(value)
summary = value[:int(size/2)] + '*'*int(size-size/2)
summary = "<strong>hash</strong>: %s" % summary
if value.startswith('*'):
summary = "<strong>algorithm</strong>: sha1_bin_hex %s" % summary
return format_html("<div>%s</div>" % summary)
示例2: test_readonly_field_has_changed
def test_readonly_field_has_changed(self):
field = ReadOnlyPasswordHashField()
self.assertFalse(field.has_changed('aaa', 'bbb'))
示例3: test_readonly_field_has_changed
def test_readonly_field_has_changed(self):
field = ReadOnlyPasswordHashField()
self.assertFalse(field._has_changed("aaa", "bbb"))