本文整理匯總了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"))