Models
You can define models by editing Manage/Models and type for example:
db.define_table("friend",db.Field("name"),db.Field("image","upload"))
The syntax is
db.Field(name,type="string",length=32,requires=validators,
required=False,unique=False,notnull=False,default=None,label=None)
where type can be 'string', 'text', 'upload', 'boolean', 'integer', 'double', 'date', 'time', 'datetime', 'password'
- db.friend is the table
- db.friend.name is the table field
- rows=db(db.friend.id>0).select() is an iterable over records
Optional attributes:
- db.friend.exposes=['name','image'] # list of fields names that should appear in self.create(...),self.update(...)
- db.friend.displays=['name','image'] # list of fields names that should appear in self.display(...)
- db.friend.represent=lambda friend: A(friend.name,_href='...') # representation of a record in self.itemize(...)
- db.friend.authentication=True # allow only logged in users to download static stored
You can use all the web2py API.