Autofill models.DateTimeField() using code

I have in my Model,
last_updated = models.DateTimeField()

I am writing a script to insert a bunch of data from CSV to SQLite3 database.
What is the code to auto insert current date+time to last_updated ?

This seems to work datetime('now')

what about:

last_updated = models.DateTimeField(auto_now=True)

On entering a new object this enters the current date and time - but what about on updating an existing item / object ? Does this auto-update ?

Maybe this might help you Sir.

yes, it should doauto-update. feom django docs:

Automatically set the field to now every time the object is saved. Useful for “last-modified” timestamps.

Model field reference | Django documentation | Django. for new object is auto_now_add

Thank you. I think this should do.

Shoutout to the great @problem_giver :smiley: