views:

60

answers:

1
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()?

+1  A: 

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.

Rishabh Manocha
For a field such as `last_updated`, `auto_now=True` will be the desirable argument to use.
ayaz