>>> from apko.main.models import IndexForm
>>> form = IndexForm()
>>> form.is_valid
<bound method IndexForm.is_valid of <apko.main.models.IndexForm object at 0xb774f48c>>
Куда рыть? Что читать? Посоветуйте, пожалуйста!
models.py
# -*- coding:utf-8 -*-
from django.db import models
from django import forms
# Create your models here.
class Filial(models.Model):
filial = models.CharField(u'Название филиала', max_length=128)
email = models.EmailField(u'E-mail')
def __unicode__(self):
return u'%s'%self.filial
class Firm(models.Model):
firm = models.CharField(u'Название фирмы', max_length=128)
code = models.CharField(u'Код фирмы', max_length=128)
def __unicode__(self):
return u'%s'%self.firm
class IndexForm(forms.Form):
filial = forms.ModelChoiceField(queryset=Filial.objects.all().order_by('filial'), label=u'Филиал')
firm = forms.ModelChoiceField(queryset=Firm.objects.all().order_by('firm'), label=u'Фирма')
client = forms.CharField(widget=forms.TextInput(attrs={'class':'in1',}), label=u'Код клиента', max_length=128)
sum = forms.FloatField(label=u'Сумма')
result = forms.BooleanField(widget=forms.CheckboxInput(attrs={'onclick':'mailswitch()'}), label=u'Сообщить результат', required=False)
email = forms.EmailField(widget=forms.TextInput(attrs={'class':'ch1','disabled':'true'}), label=u'Ваш e-mail', required=False)