Hi there,

There must be a simple way to do this, but I can't seem to figure it
out. I would like a field (name) to populate itself automatically when
a database record is created.

# test table
db.define_table("animal",
    SQLField("name","string",length=20,notnull=True,default="ANML-" +
str(db.animal.id) ), # this fails
    SQLField("sex", db.sex)
    )

after a create action, I would like the following result:
animal.id = 1
animal.name = ANML-1
....

Is this possible? Thanks for your help!

-Sebastian

PS: would be nice to have 'ANML-000001' with zeros padded according to
id number (eg. ANML-000299)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to