Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Eric Chamberlain
On Jan 14, 2010, at 6:45 AM, nameless wrote: > > > I want username field is automatically filled with this value: > > username = str(n); > > where n is a number of 10 digits ( autoincremented or random ). > > . > > I tried to add this in save method: > > username =

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Tom Evans
On Thu, Jan 14, 2010 at 6:34 PM, nameless wrote: > uuid is too long for username field ( max 30 characters ). "n" should > be a number of 10 digits :) > > Er, a UUID is a 128 bit number. In its standard 'for humans' format it is represented as 36 character hexadecimal

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Tom Evans
On Thu, Jan 14, 2010 at 2:45 PM, nameless wrote: > > > I want username field is automatically filled with this value: > > username = str(n); > > where n is a number of 10 digits ( autoincremented or random ). > > . > > I tried to add this in save method: > > username =

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Shawn Milochik
Do a Google search on 'mysql' and 'sequences.' Also, have a look at MySQL's last_insert_id() function. Maybe that's all you need to use an autonumber as a sequence. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread nameless
Sequences are best solution for me but I don't know how to implement its in django+mysql. I tought also to use id as username but I don't know how do this :-\ Could you explain me how do pleaseee ? Thank you --- On Jan 14, 4:16 pm, Shawn Milochik wrote: >

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Shawn Milochik
There are a bunch of ways you can do it. As a previous poster said, you can take 10 digits of the current timestamp. However, be wary of daylight saving time changes (if you have them on your server), and the possibility of any conflict if you change servers, have a backup server, or ever

Re: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread Stephen Emslie
How about a timestamp? import time name = str(time.time()) On Thu, Jan 14, 2010 at 2:45 PM, nameless wrote: > > > I want username field is automatically filled with this value: > > username = str(n); > > where n is a number of 10 digits ( autoincremented or random ).

Insert AUTOMATICALLY random string in username field

2010-01-14 Thread nameless
I want username field is automatically filled with this value: username = str(n); where n is a number of 10 digits ( autoincremented or random ). . I tried to add this in save method: username = str(random.randint(10,99)) but there is a collision problem when n is the same