class Person: id = fields.IntegerField('id', is_pk=True) name = fields.TextField('name', required=True) age = fields.IntegerField('age', required=True) money = fields.RealField('money', required=False, default=0.0) item_amount = fields.IntegerField('i_amount', required=True, default=100)
def test_add_column_without_default(): db = database(DB_FILENAME) class Person: id = fields.IntegerField('id', is_pk=True) db.table(Person) Person.name = fields.TextField('name', required=True, default=None) try: db.table(Person, update_table=True) except exceptions.NewColumnWithoutDefault: assert True else: assert False
def test_add_column(): db = database(DB_FILENAME) class Person: id = fields.IntegerField('id', is_pk=True) db.table(Person) db.cursor.execute('PRAGMA table_info(Person)') info = db.cursor.fetchall() assert len(info) == 1 Person.name = fields.TextField('name', required=False) db.table(Person, update_table=True) db.cursor.execute('PRAGMA table_info(Person)') info = db.cursor.fetchall() assert len(info) == 2
class AppointmentForm(forms.Form): description = fields.TextField(max_length=1000, required=False, label=_('Description'), help_text=_('What, where, how?')) invitees = fields.EmailListField( max_length=2000, required=False, label=_('Invitees'), help_text=_( 'Example: [email protected], Jane Doe <*****@*****.**>')) dates = fields.DateTimeListField(required=False, label=_('Proposed dates')) propose_more = forms.BooleanField( required=False, label=_('Invitees may propose more dates'), initial=True) name = forms.CharField(max_length=100, required=False, label=_('Your name')) email = forms.EmailField(required=True, label=_('Email address')) class Media: css = {'all': ('style/form.css', )} js = ('script/form.js', )
class Person: id = fields.IntegerField('id', is_pk=True) name = fields.TextField('name')
class Person: id = fields.IntegerField('id', is_pk=True) name = fields.TextField('name', required=False)
class Person: id = fields.IntegerField('id', is_pk=True) name = fields.TextField('name', required=True) age = fields.IntegerField('age', required=False, default=20)