My favorites | Sign in
Project Home Wiki Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 94: functions passed to 'default=' arguments in fields get called resulting in bogus default values
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by george....@gmail.com, Dec 27, 2008

create a model:

class Thingy(models.Model):
    ctime       = models.DateTimeField( default=datetime.datetime.now ) #
creation time
    mtime       = models.DateTimeField( default=datetime.datetime.now ) #
modifiication time

check the database:

   Column    |           Type           |                                
Modifiers
-------------+--------------------------+----------------------------------------------------------------------------
 ctime       | timestamp with time zone | not null
 mtime       | timestamp with time zone | not null


add the field:

    etime       = models.DateTimeField( default=datetime.datetime.now ) #
expiration time

evolve the system
    ./manage.py evolve --hint --execute
    ...yes...


then look in the database again:

   Column    |           Type           |                                
Modifiers
-------------+--------------------------+----------------------------------------------------------------------------
 ctime       | timestamp with time zone | not null
 mtime       | timestamp with time zone | not null
 etime       | timestamp with time zone | not null default '2008-12-27
22:58:28.915967+00'::timestamp with time zone

so datetime.datetime.now is being inadvertently called in the evolution
process.
Sign in to add a comment

Powered by Google Project Hosting