Hi I have a model like so:
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
However when I try to save a project I get:
coercing to Unicode: need string or buffer, long found
and from the runserver:
RuntimeWarning: DateTimeField received a naive datetime (2012-10-31 14:45:36.611622) while time zone support is active.
I'm not sure exactly what the problem is here but I'm assuming it has something to do with timezone
getting in the way of saving the DateTimeField
.
Any help would be much appreciated.