Python django.forms 模块,RegexField() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.forms.RegexField()

项目:esdc-ce    作者:erigones    | 项目源码 | 文件源码
def __init__(self, regex, max_length=None, min_length=None, *args, **kwargs):
        super(RegexField, self).__init__(max_length, min_length, *args, **kwargs)
        self.regex = regex
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_regex_convert_string():
    assert_conversion(forms.RegexField, graphene.String, '[0-9]+')
项目:LDERP    作者:Ignoramuss    | 项目源码 | 文件源码
def clean(self):
        if 'password' in self.cleaned_data and 'confirm_password' in self.cleaned_data:
            if self.cleaned_data['password'] != self.cleaned_data['confirm_password']:
                raise forms.ValidationError(_("The two password fields did not match."))
        return self.cleaned_data

# class StudentInfoForm(forms.Form):
#     stud_name = forms.RegexField(required=True, regex=r'^\w+$', label='', max_length=200, widget=forms.TextInput(attrs={'placeholder': "First Name eg: Shiv", 'autofocus':'true'}))
#     stud_school = forms.RegexField(required=True, regex=r'^\w+$', label='', max_length=200, widget=forms.TextInput(attrs={'placeholder': "Student's School's Name"}))
#     stud_standard = forms.RegexField(required=True, regex=r'^\w+$', label='', max_length=30, widget=forms.TextInput(attrs={'placeholder': "Student's Standard"}))
#     stud_div = forms.RegexField(required=True, regex=r'^\w+$', label='', max_length=30, widget=forms.TextInput(attrs={'placeholder': "Student's Division"}))
#
#     date_of_fill = forms.DateField(required=True, input_formats=['%d-%m-%Y'], label='',widget=forms.DateInput(attrs={'placeholder': "Date of Filling", 'type':"date"}))
#     date_of_birth = forms.DateField(required=True, input_formats=['%d-%m-%Y'], label='', widget=forms.DateInput(attrs={'placeholder': "Date of Birth", 'type':"date"}))
#
#     father_name = forms.CharField(required=True, label='', max_length=200, widget=forms.TextInput(attrs={'placeholder': "Father's Full Name", 'autofocus':'true'}))
#     father_contact  = forms.CharField(required=True, label='', max_length=10, widget=forms.TextInput(attrs={'placeholder': "Eg 98xxxxxxx0"}))
#     father_email = forms.EmailField(required=True, label='', widget=forms.TextInput(attrs=dict(required=True, max_length=200, placeholder="Father's Email")))
#     father_education = forms.CharField(required=True, label='', max_length=200,widget=forms.TextInput(attrs={'placeholder': "Father's Education"}))
#     father_occupation = forms.CharField(required=True, label='', max_length=200,widget=forms.TextInput(attrs={'placeholder': "Father's Occupation"}))
#
#     mother_name = forms.CharField(required=True, label='', max_length=200,  widget=forms.TextInput(attrs={'placeholder': "Mother's Full Name",'autofocus': 'true'}))
#     mother_contact = forms.CharField(required=True, label='', max_length=10, widget=forms.TextInput(attrs={'placeholder': "Eg 98xxxxxxx0"}))
#     mother_email = forms.EmailField(required=True, label='', widget=forms.TextInput(attrs=dict(required=True, max_length=200, placeholder="Mother's Email")))
#     mother_education = forms.CharField(required=True, label='', max_length=200, widget=forms.TextInput(attrs={'placeholder': "Mother's Education"}))
#     mother_occupation = forms.CharField(required=True, label='', max_length=200, widget=forms.TextInput(attrs={'placeholder': "Mother's Occupation"}))
#
#     letter_identification = forms.BooleanField()
#     let_sound_assoc = forms.BooleanField()
#     spelling = forms.BooleanField()
#     reading = forms.BooleanField()
#     comprehension = forms.BooleanField()
#     composition = forms.BooleanField()
#     grammar = forms.BooleanField()
#
#     number_identification = forms.BooleanField()
#     forget_tables = forms.BooleanField()
#     carry_borr = forms.BooleanField()
#     frac_dec = forms.BooleanField()
#     problem_int = forms.BooleanField()
#     algebra = forms.BooleanField()
#
#     awareness = forms.IntegerField()
#     acceptance = forms.IntegerField()
#     active_participation = forms.IntegerField()
#     emo_support_provided = forms.IntegerField()
#     strength_awareness = forms.IntegerField()
#     parenting_style = forms.IntegerField()