当前位置: 首页>>代码示例>>Python>>正文


Python forms.PasswordInput方法代码示例

本文整理汇总了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') 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:20,代码来源:forms.py

示例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']) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:25,代码来源:forms.py

示例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.'),
            }) 
开发者ID:nlhkabu,项目名称:connect,代码行数:23,代码来源:forms.py

示例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) 
开发者ID:getway,项目名称:diting,代码行数:24,代码来源:forms.py

示例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 
开发者ID:respawner,项目名称:peering-manager,代码行数:7,代码来源:fields.py

示例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')) 
开发者ID:dkarchmer,项目名称:django-aws-template,代码行数:9,代码来源:forms.py

示例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) 
开发者ID:chaoss,项目名称:prospector,代码行数:6,代码来源:fields.py

示例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) 
开发者ID:wagtail,项目名称:wagtail,代码行数:10,代码来源:test_edit_handlers.py

示例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) 
开发者ID:wagtail,项目名称:wagtail,代码行数:10,代码来源:test_edit_handlers.py

示例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] 
开发者ID:naver,项目名称:hubblemon,代码行数:8,代码来源:cubrid_query.py

示例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] 
开发者ID:naver,项目名称:hubblemon,代码行数:6,代码来源:memcached_query.py

示例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] 
开发者ID:naver,项目名称:hubblemon,代码行数:7,代码来源:mysql_query.py

示例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"}
        ),
    ) 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:10,代码来源:forms.py

示例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) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:8,代码来源:fields.py

示例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">',
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:14,代码来源:test_passwordinput.py


注:本文中的django.forms.PasswordInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。