You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
1016 B

# -*- coding: utf-8 -*-
from django import forms
from captcha.fields import CaptchaField
class FeedbackForm(forms.Form):
"""Форма обратной связи."""
name = forms.CharField(label=u'Имя', max_length=100, error_messages={'required': u'Укажите имя.'})
phone = forms.CharField(label=u'Телефон', max_length=30, required=False)
email = forms.EmailField(label=u'Email', max_length=30, required=False)
msg = forms.CharField(label=u'Текст сообщения', max_length=500, widget=forms.Textarea(),
error_messages={'required': u'Введите сообщение.'})
captcha = CaptchaField(label=u'Код с картинки', error_messages={'required': u'Введите код с картинки.'})
def clean(self):
if not self.cleaned_data.get('phone') and not self.cleaned_data.get('email'):
raise forms.ValidationError(u'Введите контактную информацию.')
return self.cleaned_data