That requires creating a sequence. How about a uuid? import uuid
Field(...,compute=str(uuid.uuid4())) On Oct 26, 8:27 am, shukalo83 <[email protected]> wrote: > Thank You Massimo on your quick responce. > > Actually, I don't need an id value. I need some kind of unique, > autoincremented integer. I though I could copy an id value but..., you > provided enough resons that this cannot be done. > > Actually, fields 'jmbg' and 'jib' are xor combination, so to call it. > (If one is present, other is not), so if 'jib' is entered, 'jmbg' > should not be. In the same time both should be unique and thus could > not left empty. I thought some kind of incremented integer would do > the job. > > On Oct 26, 3:08 pm, mdipierro <[email protected]> wrote: > > > This cannot be: > > > default=db.contacts.id > > > - syntactically because the right hand side has to be a field value > > not a field object. > > > - logically because you need the id value to fill the field before the > > record is created but an id is assigned donly after the record is > > created > > > - this causes duplication of information (attempts to put id is in two > > places) and it is to be avoided. > > > Perhaps if you explain us why you want to do this, we can suggest a > > better way. > > > Massimo > > > On Oct 26, 5:20 am, shukalo83 <[email protected]> wrote: > > > > Hello! > > > > I'm new to web2py and need something like this. I'm opened to all > > > kind of suggestions > > > > db.define_table('contacts', > > > Field('first'), > > > Field('last'), > > > > Field('jmbg',unique=True,default=db.contacts.id), #this doesn't work > > > but, if nothing is entered here I need it to be id value > > > > Field('jib',unique=True,default=db.contacts )) > >

