嗨,我有一个这样的模型:
from datetime import datetime
class Project(models.Model):
created = models.DateTimeField(editable=False)
updated = models.DateTimeField(editable=False)
product = models.ForeignKey('tool.product')
module = models.ForeignKey('tool.module')
model = models.ForeignKey('tool.model')
zipcode = models.IntegerField(max_length=5)
def save(self, **kwargs):
if not self.id:
self.created = datetime.now()
self.updated = datetime.now()
super(Project, self).save()
def __unicode__(self):
return self.id
但是,当我尝试保存项目时,我得到:
coercing to Unicode: need string or buffer, long found
并从运行服务器:
RuntimeWarning: DateTimeField received a naive datetime (2012-10-31 14:45:36.611622) while time zone support is active.
我不确定到底是什么问题,但我假设它与timezone
妨碍保存DateTimeField
.
任何帮助将非常感激。