web2py can do alias but that is intended as a means of joining the
same table twice.
With the latest web2py you ca do Field('Customer','id') and it has the
effect of renaming the 'id' field. This is intended and a means to
deal with some legacy tables. It has not been tested much although it
should work. I would not recommend it.
I would suggest:
import uuid
db.define_table('Customer',Field('Customerid',unique=True))
db.Customer.Customerid.default=str(uuid.uuid4())[:6]
db.Customer.Customerid.writable=False
Mind only 6 chars there will be a probability of conflicts and they
will result in errors on insert. If the number of items is much less
than 16^6, the probability of a conflict is small anyway.
Massimo
On Nov 25, 8:19 am, Gibran Rodriguez <[email protected]> wrote:
> hello there
>
> I was wondering how to modify the name or alias ( I don't know if I
> have understood correctly the difference? is there any difference
> between name of the field and alias?) also, how to assign the length
> id given by the database I have the following example
>
> db.define_table('Customer',Field('Customer','id'),Field
> ('Customerid'),
>
> will this be then Customer.Customerid?
>
> and I would like to have an id of 6 characters generated randomly ( I
> don't care if it's string or integer or numbers or letters just
> generated randomly and with 6 of length). Can anybody tell me how is
> this possible?
>
> thank you in advance
>
> regards,
>
> brangi
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---