newthing = Link(user=request.user,last_updated=datetime.datetime.now())
However, this uses datetime , not the MYSQL "now()".
How can I use mysql's now()?
newthing = Link(user=request.user,last_updated=datetime.datetime.now())
However, this uses datetime , not the MYSQL "now()".
How can I use mysql's now()?
I'm not sure if this uses the MySQL now()
call, but the right way to do this in Django is to use the auto_now_add
or auto_add
options on a DateField/DateTimeField:
class Link(models.Model):
...
last_updated = models.DateTimeField(auto_now_add = True)
...
Note: I am assuming here that Link
is a Model.