class FeedbackForm(ModelForm): captcha = CaptchaField() captcha = CaptchaField(widget=CaptchaTextInput({'class': 'form-control'})) class Meta: model = Feedback fields = ['email', 'subject', 'message'] widgets = { 'email': TextInput( attrs={ 'type': 'email', 'class': 'form-control', 'id': 'email', 'rows': 1, 'cols': 15 }), 'subject': TextInput( attrs={ 'type': 'text', 'class': 'form-control', 'id': 'subject', 'rows': 1, 'cols': 15 }), 'message': Textarea(attrs={ 'class': 'form-control', 'id': 'message', 'rows': 5, 'cols': 20 }), }
class FeedbackForm(forms.Form): template_name = 'email.html' subject = u'Отзывы' FORM_ERRORS = { 'required': u'Обязательное поле', 'invalid': u'Недопустимое значение', 'captcha': { 'invalid': u'Код введен неверно', 'required': u'Обязательное поле', } } name = forms.CharField(label='Имя', widget=forms.TextInput(attrs={'class': u'is-required is-name'}), error_messages=FORM_ERRORS) email = forms.EmailField(label='E-mail', widget=forms.TextInput(attrs={'class': u'is-required is-email'}), error_messages=FORM_ERRORS) message = forms.CharField(label='Сообщение', widget=forms.Textarea(attrs={'class': u'is-required is-message'}), error_messages=FORM_ERRORS) captcha = CaptchaField(label='Текст на картинке', widget=CaptchaTextInput(attrs={'class': u'is-required is-captcha'}), error_messages=FORM_ERRORS['captcha']) def get_context_data(self): return {'data': self.cleaned_data} def get_message_text(self): html = get_template(self.template_name) html = html.render(Context(self.get_context_data())) return html def send_email(self): connection = get_connection() html = self.get_message_text() msg = EmailMultiAlternatives(self.subject, html, '', ['*****@*****.**', '*****@*****.**'], connection=connection) # msg.attach_alternative(html, "text/html") msg.content_subtype = "html" msg.send()
class ContactLeaderForm(forms.Form): your_name = forms.CharField(label='Your Name', max_length=100, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) your_email = forms.EmailField(label='Your Email', max_length=100, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) subject = forms.CharField(label='Subject', max_length=50, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) your_message = forms.CharField(label='Your Message', required=True, widget=forms.Textarea(attrs={'class':'form-control'})) captcha = CaptchaField(widget=CaptchaTextInput(attrs={'class':'form-control'})) system_subject = forms.CharField(required=True, widget=forms.HiddenInput()) leader = forms.ModelChoiceField(queryset=Leader.objects.filter(active=True), required=True, widget=forms.HiddenInput()) def send_contact_email(self): name = self.cleaned_data.get('your_name', 'unknown') email = self.cleaned_data['your_email'] message = self.cleaned_data['your_message'] leader = self.cleaned_data['leader'] system_subject = self.cleaned_data['system_subject'] user_subject = self.cleaned_data['subject'] subject = system_subject + ' - ' + user_subject leader_email = leader.email context = {'name':name, 'email': email, 'message':message} body = render_to_string('contact_email_template.html', context) send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [leader_email], fail_silently=False)
class QuestionForm(forms.ModelForm): name = forms.CharField( max_length=255, widget=forms.TextInput(attrs={'placeholder': u'Имя'}), label=u'Представьтесь') captcha = CaptchaField( widget=CaptchaTextInput(attrs={ 'placeholder': u'Введите код', 'class': u'form-control captcha-inline' }), label=u'Код проверки') email = EmailField( max_length=50, widget=forms.EmailInput(attrs={'placeholder': u'*****@*****.**'}), label=u'E-mail') question = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={ 'placeholder': 'Вопрос', 'rows': 5 }), label=u'Вопрос') class Meta: model = Question fields = ['name', 'email', 'question']
class PrayerForm(forms.Form): your_name = forms.CharField(label='Your Name', max_length=100, required=False, widget=forms.TextInput(attrs={'class':'form-control'}), help_text="(Optional)") your_email = forms.EmailField(label='Your Email', max_length=100, required=False, widget=forms.TextInput(attrs={'class':'form-control'}), help_text="(Optional)") prayer_request = forms.CharField(label='Prayer Request', required=True, widget=forms.Textarea(attrs={'class':'form-control'})) prayer_meeting = forms.BooleanField(required=False, label='Please pray for request during prayer meeting') follow_up = forms.BooleanField(required=False, label='Please follow up with me') captcha = CaptchaField(widget=CaptchaTextInput(attrs={'class':'form-control'})) def send_prayer_email(self): name = self.cleaned_data.get('your_name', 'unknown') email = self.cleaned_data.get('your_email','unknown') prayer_request = self.cleaned_data['prayer_request'] prayer_meeting = self.cleaned_data['prayer_meeting'] follow_up = self.cleaned_data['follow_up'] subject = "Living Hope Prayer request from %s" % name context = {'name':name, 'prayer_request': prayer_request, 'prayer_meeting':prayer_meeting, 'follow_up':follow_up} body = render_to_string('prayer_email_template.html', context) send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, settings.EMAIL_RECIPIENTS, fail_silently=False)
class RegisterForm(forms.Form): gender = ( ('male', "男"), ('female', "女"), ) username = forms.CharField( label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control'})) password1 = forms.CharField( label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'})) password2 = forms.CharField( label="确认密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'})) email = forms.EmailField( label="邮箱地址", widget=forms.EmailInput(attrs={'class': 'form-control'})) sex = forms.ChoiceField( label='性别', choices=gender, widget=forms.Select(attrs={'class': 'form-control'})) captcha = CaptchaField( label='验证码', widget=CaptchaTextInput(attrs={'class': 'form-control'}))
class ContactForm(forms.Form): name = forms.CharField(label='', max_length='100', widget=forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter your name', 'aria-describedby': 'nameHelpBlock' })) email = forms.EmailField(label='Your email address', widget=forms.EmailInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter your email', 'aria-describedby': 'emailHelpBlock' })) message = forms.CharField(widget=forms.Textarea( attrs={ 'class': 'form-control', 'placeholder': 'Enter your message', 'aria-describedby': 'messageHelpBlock' })) captcha = CaptchaField(widget=CaptchaTextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter captcha text' }))
class UserRegisterForm(forms.Form): Username = forms.CharField(widget=forms.TextInput( attrs={ "class": "form-control name", "placeholder": "Enter Your Username" })) Email = forms.EmailField(widget=forms.TextInput( attrs={ "class": "form-control mail", "placeholder": "Type Your Email", 'required': 'True' })) Password = forms.CharField(widget=forms.PasswordInput( attrs={ "class": "form-control pass", "placeholder": "Enter Your Password" })) Confirm_password = forms.CharField( label="Confirm password", widget=forms.PasswordInput(attrs={ "class": "form-control pass", "placeholder": "Confirm Your Password" })) captcha = CaptchaField(widget=CaptchaTextInput( attrs={ 'class': 'form-control', "placeholder": "Enter the captcha", 'style': "margin-top:5px;margin-bottom:15px;" })) class Meta: model = User fileds = [ 'email', 'username', ] def clean_Username(self): uname = self.cleaned_data.get("Username") set = User.objects.filter(username=uname) if set.exists(): raise forms.ValidationError("Username exist try another one.") return uname def clean_Email(self): email = self.cleaned_data.get("Email") set = User.objects.filter(email=email) if set.exists(): raise forms.ValidationError("Email exist try another one.") return email def clean(self): data = self.cleaned_data Password = self.cleaned_data.get('Password') Password2 = self.cleaned_data.get('Confirm_password') if Password is None: raise form.ValidationError("Enter some password.") if Password != Password2: raise forms.ValidationError("Passwords didn't match") return data
class UserCreationForm(forms.ModelForm): password1 = forms.CharField(label='', widget=forms.PasswordInput(attrs={'placeholder': 'Пароль', 'required': ''})) password2 = forms.CharField(label='', widget=forms.PasswordInput(attrs={'placeholder': 'Пароль еще раз', 'required': ''})) username = forms.RegexField(label='', max_length=30, regex=r'^[\w.@+-]+$', widget=forms.TextInput(attrs={'placeholder': 'Логин', 'required': '', 'class': 'login', 'autocomplete': 'off'})) email = forms.EmailField(label='', widget=forms.EmailInput(attrs={'placeholder': 'Email', 'required': '', 'autocomplete': 'off'})) captcha = CaptchaField(label='', widget=CaptchaTextInput(attrs={'placeholder': 'Captcha', 'required': '', 'class': 'captcha', 'autocomplete': 'off'})) error_messages = { 'invalid_login': ("Please enter a correct username and password. " "Note that both fields are case-sensitive."), 'no_cookies': ("Your Web browser doesn't appear to have cookies " "enabled. Cookies are required for logging in."), 'inactive': ("This account is inactive."), } class Meta: model = User fields = ('email', 'username') def clean_password2(self): password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("Passwords don't match") return password2 def save(self, commit=True): user = super(UserCreationForm, self).save(commit=False) user.set_password(self.cleaned_data["password1"]) if commit: user.save() return user
class CallbackForm(forms.ModelForm): name = forms.CharField( max_length=255, widget=forms.TextInput(attrs={'placeholder': u'Имя'}), label=u'Представьтесь') phone = forms.CharField( max_length=255, widget=forms.TextInput(attrs={ 'placeholder': u'+7 (', 'class': u'form-control masked_input_mobile' }), required=False, label=u'Телефон') captcha = CaptchaField( widget=CaptchaTextInput(attrs={ 'placeholder': u'Введите код', 'class': u'form-control captcha-inline' }), label=u'Код проверки') def __init__(self, *args, **kwargs): super(CallbackForm, self).__init__(*args, **kwargs) self.fields['callback_delta'].choices = CallbackDeltaEnum.choices() self.fields['callback_delta'].initial = 0 class Meta: model = Callback fields = ['name', 'phone', 'callback_delta']
class DonationContactForm(forms.Form): your_name = forms.CharField(label='Your Name', max_length=100, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) your_email = forms.EmailField(label='Your Email', max_length=100, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) your_message = forms.CharField(label='Your Message', required=True, widget=forms.Textarea(attrs={'class':'form-control'})) captcha = CaptchaField(widget=CaptchaTextInput(attrs={'class':'form-control'})) donation_posting = forms.ModelChoiceField( queryset=DonationPosting.objects.filter(active=True, approved=True), required=True, widget=forms.HiddenInput()) def send_contact_email(self): name = self.cleaned_data.get('your_name', 'unknown sender') email = self.cleaned_data['your_email'] message = self.cleaned_data['your_message'] donation_posting = self.cleaned_data['donation_posting'] subject = 'Living Hope donation posting response' donor_email = donation_posting.contact_email context = {'name':name, 'email': email, 'message':message, 'donation':donation_posting} body = render_to_string('contact_email_donation_template.html', context) send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [donor_email], fail_silently=False)
def testIssue12ProperInstantiation(self): """ This test covers a default django field and widget behavior It not assert anything. If something is wrong it will raise a error! """ settings.CAPTCHA_OUTPUT_FORMAT = u'%(image)s %(hidden_field)s %(text_field)s' widget = CaptchaTextInput(attrs={'class': 'required'}) CaptchaField(widget=widget)
class RegisterForm(forms.Form): gender = ( ('male', "男"), ('female', "女"), ) username = forms.CharField( label="用户名", min_length=2, max_length=16, error_messages={ 'required': '用户名不能为空.', #'invalid': '密码必须至少包含数字和字母', 'min_length': "用户名不能少于2个字符", 'max_length': "用户名不能大于16个字符" }, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': '至少2个字符,可以是中文' })) #password1 = forms.CharField(label="密码", max_length=12, widget=forms.PasswordInput(attrs={'class': 'form-control'})) password1 = forms.RegexField( '^(?=.*[0-9])(?=.*[a-zA-Z]).{6,12}$', #这里正则匹配验证要求密码了里面至少包含字母、数字 label="密码", min_length=6, max_length=12, error_messages={ 'required': '密码不能为空.', 'invalid': '密码必须至少包含数字和字母', 'min_length': "密码长度不能小于6个字符", 'max_length': "密码长度不能大于12个字符" }, widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': '密码6-12个字符,需要至少包含数字和字母' })) password2 = forms.CharField( label="确认密码", max_length=12, widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': '请再次输入密码' })) phone_number = forms.CharField( label="电话号码", min_length=6, max_length=15, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': '电话号码' })) email = forms.EmailField(label="邮箱地址", widget=forms.EmailInput(attrs={ 'class': 'form-control', 'placeholder': '请输入邮箱' })) sex = forms.ChoiceField(label='性别', choices=gender) captcha = CaptchaField( label='验证码', widget=CaptchaTextInput(attrs={'class': 'form-control'}))
class CreateTeamForm(forms.ModelForm): teamName = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': '请输入队伍名字' }), validators=[delete_team_exit_validate], error_messages={ 'required': '请填写队伍名字', 'max_length': '队伍名不得多于10位字符', 'min_length': '队伍名不得少于3位字符', }, label='队伍名', max_length=10, min_length=3, required=True) teamEmail = forms.EmailField( widget=forms.EmailInput(attrs={ 'class': 'form-control', 'placeholder': '请输入队伍Email' }), validators=[team_email_validate], error_messages={ 'required': '请填写队伍Email', 'max_length': 'Email不得多于30位字符', 'min_length': 'Email不得少于5位字符', }, label='队伍Email', max_length=30, min_length=5, required=True) captcha = CaptchaField(label='验证码', widget=CaptchaTextInput(attrs={ 'class': 'form-control', 'placeholder': '请输入验证码' }, ), error_messages={ "invalid": u"验证码错误", "required": u"请输入验证码", }) # 验证队伍存在性 def clean_team_name(self): cleaned_data = super(CreateTeamForm, self).clean() teamName = cleaned_data.get('teamName') teamEmail = cleaned_data.get('teamEmail') team = Team.objects.filter(teamName=teamName) if team: raise forms.ValidationError(u'此队伍已经被使用') team = Team.objects.filter(email=teamEmail) if team: raise forms.ValidationError(u'此Email已经被使用') return cleaned_data class Meta: model = Team fields = ('teamName', 'teamEmail', 'captcha')
class FeedbackForm(ModelForm): captcha = CaptchaField(widget=CaptchaTextInput(attrs={'placeholder': 'Üsteki kodu girin', 'class': 'input-block-level form-control'})) class Meta: model = UserFeedback fields = ('content',) widgets = { 'content': Textarea(attrs={'placeholder': "Görüşleriniz...", 'class': 'input-block-level form-control'}), }
class PasswordResetForm(ModelForm): captcha = CaptchaField(widget=CaptchaTextInput(attrs={'placeholder': 'Üsteki kodu girin', 'class': 'input-block-level form-control'})) class Meta: model = User fields = ('email',) widgets = { 'email': TextInput(attrs={'placeholder': "@bilgiedu.net veya @bilgi.edu.tr", 'class': 'input-block-level form-control'}) }
class messageForm(forms.ModelForm): captcha = CaptchaField(widget=CaptchaTextInput(attrs={ 'class': "form-captcha", 'placeholder': '验证码' })) class Meta: model = Message fields = ['name', 'email', 'phone', 'message']
class VisitForm(forms.ModelForm): name = forms.CharField( max_length=255, widget=forms.TextInput(attrs={'placeholder': u'Имя'}), label=u'Представьтесь') phone = forms.CharField( max_length=255, widget=forms.TextInput(attrs={ 'placeholder': u'+7 (', 'class': u'form-control masked_input_mobile' }), required=False, label=u'Телефон') email = EmailField( max_length=50, widget=forms.EmailInput(attrs={'placeholder': u'*****@*****.**'}), label=u'E-mail') description = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={ 'placeholder': 'Пожелания', 'rows': 5 }), label=u'Пожелания') captcha = CaptchaField( widget=CaptchaTextInput(attrs={ 'placeholder': u'Введите код', 'class': u'form-control captcha-inline' }), label=u'Код проверки') def __init__(self, *args, **kwargs): super(VisitForm, self).__init__(*args, **kwargs) self.fields['procedure'].choices = ProceduresEnum.choices() self.fields['procedure'].initial = 0 self.fields['purpose'].choices = [[None, 'Не имеет значение']] + list( VisitPurpose.objects.values_list('id', 'title')) self.fields['purpose'].initial = None self.short_fields = [ 'phone', 'purpose', 'email', 'procedure', 'visit_date', 'visit_time' ] if hasattr(self.instance, 'visit_date') and not self.instance.visit_date: self.fields['visit_date'].initial = timezone.localtime( timezone.now()).strftime('%Y-%m-%d') if hasattr(self.instance, 'visit_time') and not self.instance.visit_time: self.fields['visit_time'].initial = timezone.localtime( timezone.now()).strftime('%H:%M') class Meta: model = Visit fields = [ 'name', 'phone', 'email', 'purpose', 'procedure', 'visit_date', 'visit_time', 'description' ]
class CustomUserSignUpForm(UserCreationForm): email = forms.EmailField(max_length=UserConstants.EMAIL_MAX_LENGTH.value, required=True, label="id_email") captcha = CaptchaField(widget=CaptchaTextInput( attrs={"placeholder": CaptchaConstants.PLACE_HOLDER_CAPTCHA.value})) class Meta: model = CustomUser fields = ("email", "password1", "password2", "captcha")
class UserForm(forms.Form): username = forms.CharField( label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control'})) password = forms.CharField( label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'})) captcha = CaptchaField( label='验证码', widget=CaptchaTextInput(attrs={'class': 'form-control'}))
class UserForm(ModelForm): captcha = CaptchaField(widget=CaptchaTextInput(attrs={'placeholder': 'Üsteki kodu girin', 'class': 'input-block-level form-control'})) class Meta: model = User fields = ('email', 'first_name', 'last_name', 'password') widgets = { 'password': PasswordInput(attrs={'placeholder': "Parola", 'class': 'input-block-level form-control'}), 'email': TextInput(attrs={'placeholder': "@bilgiedu.net veya @bilgi.edu.tr", 'class': 'input-block-level form-control'}), 'first_name': TextInput(attrs={'placeholder': "Ad", 'class': 'input-block-level form-control'}), 'last_name': TextInput(attrs={'placeholder': "Soyad", 'class': 'input-block-level form-control'}), }
class BasePersonForm(forms.ModelForm): gender = forms.CharField(widget=forms.Select( choices=((u'男', '男'), (u'女', '女')), attrs={ 'class': 'form-control', 'placeholder': '请选择性别' }, ), label='性别', max_length=8, required=True, error_messages={'required': '请选择性别'}) institute = forms.CharField(widget=forms.Select( choices=( (u'信息与通信工程学院', '信息与通信工程学院'), (u'电子工程学院', '电子工程学院'), (u'计算机学院', '计算机学院'), (u'自动化学院', '自动化学院'), (u'数字媒体与设计艺术学院', '数字媒体与设计艺术学院'), (u'现代邮政学院', '现代邮政学院'), (u'网络空间安全学院', '网络空间安全学院'), (u'光电信息学院', '光电信息学院'), (u'理学院', '理学院'), (u'经济管理学院', '经济管理学院'), (u'公共管理学院', '公共管理学院'), (u'人文学院', '人文学院'), (u'国际学院', '国际学院'), (u'软件学院', '软件学院'), ), attrs={ 'class': 'form-control', 'placeholder': '请选择学院' }, ), label='学院', max_length=15, required=True, error_messages={'required': '请选择学院'}) captcha = CaptchaField(label='验证码', widget=CaptchaTextInput(attrs={ 'class': 'form-control', 'placeholder': '请输入验证码' }, ), error_messages={ "invalid": u"验证码错误", "required": u"请输入验证码", }) class Meta: model = Person fields = ('gender', 'institute', 'captcha')
class DonationPostingForm(forms.ModelForm): captcha = CaptchaField(widget=CaptchaTextInput( attrs={'class':'form-control'})) class Meta: model = DonationPosting fields = ['seeking', 'name', 'contact_name', 'contact_email', 'description'] widgets = {'name': forms.TextInput(attrs={'class':'form-control'}), 'contact_name': forms.TextInput(attrs={'class':'form-control'}), 'contact_email': forms.TextInput(attrs={'class':'form-control'}), 'description': forms.Textarea(attrs={'class':'form-control'}), 'seeking': forms.Select(attrs={'class':'form-control'}) }
def __init__(self, *args, **kwargs): super(RegisterForm, self).__init__(*args, **kwargs) self.fields['username'].widget = widgets.TextInput( attrs={'placeholder': '请输入用户名'}) self.fields['email'].widget = widgets.EmailInput( attrs={'placeholder': '请输入邮箱地址'}) self.fields['password1'].widget = widgets.PasswordInput( attrs={'placeholder': '请输入密码'}) self.fields['password2'].widget = widgets.PasswordInput( attrs={'placeholder': '请确认密码'}) self.fields['captcha'].widget = CaptchaTextInput( attrs={'placeholder': '请输入验证码'})
class GuestForm(forms.Form): Email = forms.EmailField(widget=forms.TextInput( attrs={ "class": "form-control mail", "placeholder": "Type Your Email", 'required': 'True' })) captcha = CaptchaField(widget=CaptchaTextInput( attrs={ 'class': 'form-control', "placeholder": "Enter the captcha", 'style': "margin-top:5px;margin-bottom:15px;" }))
def __init__(self, *args, **kwargs): fields = ( CharField(show_hidden_initial=True), CharField(), ) if 'error_messages' not in kwargs or 'invalid' not in kwargs.get('error_messages'): if 'error_messages' not in kwargs: kwargs['error_messages'] = {} kwargs['error_messages'].update({'invalid': ugettext_lazy('Invalid CAPTCHA')}) kwargs['widget'] = kwargs.pop('widget', CaptchaTextInput(output_format=kwargs.pop('output_format', None))) super(CaptchaField, self).__init__(fields, *args, **kwargs)
class FeedbackMessageForm(forms.ModelForm): captcha = CaptchaField( label=_('Type the code shown'), widget=CaptchaTextInput(attrs={'class': 'captcha-input'})) class Meta: model = Message fields = ( 'name', 'email', 'text', 'captcha', )
class RegisterForm(forms.ModelForm): # 自定义的表单字段属性在Meta类中定义没有起效果 confirm_password = forms.CharField( label='确认密码', max_length=240, widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': '确认密码' })) captcha = CaptchaField( label='验证码', required=True, error_messages={'required': '验证码不能为空'}, widget=CaptchaTextInput(attrs={'class': 'form-control'})) class Meta: model = models.User fields = [ 'username', 'email', 'sex', 'password', 'confirm_password', 'captcha' ] widgets = { 'username': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': '用户名', 'autofocus': '' }), 'email': forms.EmailInput(attrs={ 'class': 'form-control', 'placeholder': '邮箱' }), 'password': forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': '密码' }), 'confirm_password': forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': '确认密码' }) } labels = { 'username': '******', 'email': '邮箱', 'sex': '性别', 'password': '******' }
class RenewalModelForm(forms.ModelForm): captcha = CaptchaField(widget=CaptchaTextInput(attrs={'class': 'form-control'})) class Meta: model = License fields=('license_no', 'captcha') def __init__(self, *args, **kwargs): super(RenewalModelForm, self).__init__(*args, **kwargs) self.fields['license_no'].label = "License Number" self.fields['license_no'].widget.attrs['placeholder'] = "Enter License Number" self.fields['captcha'].label = "Text Verification" self.fields['captcha'].widget.attrs['placeholder'] = "Enter Captcha"
class SubscriptionForm(forms.Form): name = forms.CharField( max_length=255, widget=forms.TextInput(attrs={'placeholder': u'Имя'}), label=u'Представьтесь') email = EmailField( max_length=50, widget=forms.EmailInput(attrs={'placeholder': u'*****@*****.**'}), label=u'E-mail') # course = forms.CharField(widget=forms.ChoiceField(attrs={'placeholder': u'Направление'}), label=u'Направление:') captcha = CaptchaField( widget=CaptchaTextInput(attrs={ 'placeholder': u'Введите код', 'class': u'form-control captcha-inline' }), label=u'Код проверки')