本文整理汇总了Python中django.forms.PasswordInput方法的典型用法代码示例。如果您正苦于以下问题:Python forms.PasswordInput方法的具体用法?Python forms.PasswordInput怎么用?Python forms.PasswordInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms
的用法示例。
在下文中一共展示了forms.PasswordInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, *args, **kwargs):
active = kwargs.pop('active', None)
request = kwargs.pop('request', None)
super(AdminUserForm, self).__init__(*args, **kwargs)
if not kwargs.get('instance', None):
self.fields['is_active'].initial = True
if active == 'add':
self.fields['password_1'] = forms.CharField(widget=forms.PasswordInput, label="Password")
self.fields['password_2'] = forms.CharField(widget=forms.PasswordInput, label="Repeat password")
if request and not request.user.is_admin:
self.fields.pop('is_staff', None)
self.fields.pop('is_admin', None)
if request and not request.user.is_superuser:
self.fields.pop('is_superuser')
示例2: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, *args, **kwargs):
self.connection = kwargs.pop('connection')
if not self.connection:
self.connection = models.SQLConnection.objects.get(
pk=kwargs.get('instance').payload['connection_id'])
super().__init__(*args, **kwargs)
if not self.connection.db_password:
self.fields['db_password'] = forms.CharField(
max_length=models.CHAR_FIELD_MID_SIZE,
label=_('Password'),
widget=forms.PasswordInput,
required=True,
help_text=_('Authentication for the database connection'))
if not self.connection.db_table:
self.fields['db_table'] = forms.CharField(
max_length=models.CHAR_FIELD_MID_SIZE,
label=_('Table name'),
required=True,
help_text=_('Table to load'))
self.set_fields_from_dict(['db_table'])
示例3: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
super(UpdateEmailForm, self).__init__(*args, **kwargs)
self.fields['email'] = forms.EmailField(
initial=self.user.email,
widget=forms.EmailInput(attrs={
'placeholder': _('Email')
}),
error_messages={
'required': _('Please enter your new email address.'),
'invalid': _('Please enter a valid email address.')
})
self.fields['password'] = forms.CharField(
widget=forms.PasswordInput(attrs={
'placeholder': _('Password')
}),
error_messages={
'required': _('Please enter your password.'),
})
示例4: save
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def save(self, category="default"):
if not self.is_bound:
raise ValueError("Form is not bound")
db_settings = Setting.objects.all()
if self.is_valid():
with transaction.atomic():
for name, value in self.cleaned_data.items():
field = self.fields[name]
if isinstance(field.widget, forms.PasswordInput) and not value:
continue
if value == to_form_value(getattr(db_settings, name).value):
continue
defaults = {
'name': name,
'category': category,
'value': to_model_value(value)
}
Setting.objects.update_or_create(defaults=defaults, name=name)
else:
raise ValueError(self.errors)
示例5: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, password_source="password", render_value=False, *args, **kwargs):
widget = kwargs.pop("widget", forms.PasswordInput(render_value=render_value))
label = kwargs.pop("label", "Password")
super().__init__(widget=widget, label=label, *args, **kwargs)
self.widget.attrs["password-source"] = password_source
示例6: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, *args, **kwargs):
super(AllauthLoginForm, self).__init__(*args, **kwargs)
self.fields['password'].widget = forms.PasswordInput()
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', 'Sign In', css_class='btn btn-lg btn-success btn-block'))
示例7: formfield
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def formfield(self, form_class=forms.CharField, **kwargs):
kwargs['widget'] = forms.PasswordInput
return super().formfield(form_class=form_class, **kwargs)
示例8: test_get_form_for_model_with_widget_overides_by_class
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def test_get_form_for_model_with_widget_overides_by_class(self):
EventPageForm = get_form_for_model(
EventPage, form_class=WagtailAdminPageForm,
widgets={'date_from': forms.PasswordInput})
form = EventPageForm()
self.assertEqual(type(form.fields['date_from']), forms.DateField)
self.assertEqual(type(form.fields['date_from'].widget), forms.PasswordInput)
示例9: test_get_form_for_model_with_widget_overides_by_instance
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def test_get_form_for_model_with_widget_overides_by_instance(self):
EventPageForm = get_form_for_model(
EventPage, form_class=WagtailAdminPageForm,
widgets={'date_from': forms.PasswordInput()})
form = EventPageForm()
self.assertEqual(type(form.fields['date_from']), forms.DateField)
self.assertEqual(type(form.fields['date_from'].widget), forms.PasswordInput)
示例10: auth_fields
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def auth_fields(param):
id = forms.CharField(label = 'id', required = False)
pw = forms.CharField(label = 'pw', widget = forms.PasswordInput(), required = False)
db = forms.CharField(label = 'db', required = False)
port = forms.CharField(label = 'port', required = False)
return [id, pw, db, port]
示例11: auth_fields
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def auth_fields(param):
id = forms.CharField(label = 'id', required = False)
pw = forms.CharField(label = 'pw', widget = forms.PasswordInput(), required = False)
return [id, pw]
示例12: auth_fields
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def auth_fields(param):
id = forms.CharField(label = 'id', required = False)
pw = forms.CharField(label = 'pw', widget = forms.PasswordInput(), required = False)
db = forms.CharField(label = 'db', required = False)
return [id, pw, db]
示例13: passphrase_field
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def passphrase_field(label):
return forms.CharField(
max_length=64,
label=label,
widget=forms.PasswordInput(
attrs={"autocomplete": "off", "class": "form-control"}
),
)
示例14: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def __init__(self, *args, **kwargs):
kwargs.setdefault("max_length", 4096)
kwargs.setdefault("min_length", 12)
kwargs.setdefault("widget", forms.PasswordInput)
super(PasswordCheckField, self).__init__(*args, **kwargs)
示例15: test_render_value_true
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import PasswordInput [as 别名]
def test_render_value_true(self):
"""
The render_value argument lets you specify whether the widget should
render its value. For security reasons, this is off by default.
"""
widget = PasswordInput(render_value=True)
self.check_html(widget, 'password', '', html='<input type="password" name="password">')
self.check_html(widget, 'password', None, html='<input type="password" name="password">')
self.check_html(
widget, 'password', 'test@example.com',
html='<input type="password" name="password" value="test@example.com">',
)