Date field with default value in the database

0

When I create a DataTimeField type field in Django, it has already been defined so that it contains the current date in this way:

dt = models.DateTimeField(auto_now_add=True)

or

dt = models.DataTimeField(auto_now=True)

But that way the date and time is inserted by the current date and time is the Django object, if I make an insert via SQL (outside of Django) the date field (dt) will be mandatory but not automatically filled in.

With SQL I can do it this way:

dt DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP

How can I create the table in Django so that the date field is populated automatically when a record is inserted externally in SQLite3?

    
asked by anonymous 04.12.2018 / 18:10

0 answers