Django. default=datetime.now() problem
- by Shamanu4
Hello. I've such db model:
from datetime import datetime
class TermPayment(models.Model):
dev_session = models.ForeignKey(DeviceSession, related_name='payments')
user_session = models.ForeignKey(UserSession, related_name='payment')
date = models.DateTimeField(default=datetime.now(),blank=True)
sum = models.FloatField(default=0)
cnt = models.IntegerField(default=0)
class Meta:
db_table = 'term_payments'
ordering = ['-date']
and here new instance is added:
# ...
tp = TermPayment()
tp.dev_session = self.conn.session # device session hash
tp.user_session = self.session # user session hash
tp.sum = sum
tp.cnt = cnt
tp.save()
But i've a problem: all records in database have the same value in date field - the date of the first payment. After server restart - one record have new date and others have the same as first after restart. It's look like some data cache is using but I can't found where.
database: mysql 5.1.25
django v1.1.1