Re: method as default field option

2006-08-03 Thread Alan Green
On 8/3/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > What you want is to pass in a callable for the default value (not the > result of calling the callable, which is what you are doing now). See > http://www.djangoproject.com/documentation/models/field_defaults/ for an > example. Callable d

Re: method as default field option

2006-08-03 Thread bernie2004
Malcolm Tredinnick wrote: > The reason you are getting the same values all the time is because the > random.randint(1,1000) and time.time() calls are being evaluated when > the CharFiueld instance is created, which is at your model *class* > creation time (i.e. import time, essentially). Not when

Re: method as default field option

2006-08-02 Thread Malcolm Tredinnick
On Wed, 2006-08-02 at 18:41 -0700, bernie2004 wrote: > i would really like to know if there is a way around getting > the same values when adding new entries through the admin > when using defaults like those: > > models.CharField( default=random.randint(1,1000) ) > or > models.CharField( default

method as default field option

2006-08-02 Thread bernie2004
i would really like to know if there is a way around getting the same values when adding new entries through the admin when using defaults like those: models.CharField( default=random.randint(1,1000) ) or models.CharField( default=time.time() ) or in other words: is there any way to insert by de