當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。