3YOURMIND / django-add-default-value

This django Migration Operation can be used to transfer a Fields default value to the database scheme.
Apache License 2.0
138 stars 20 forks source link

how can I set default current timestmp in mySQL #39

Open SuphattraT opened 1 year ago

SuphattraT commented 1 year ago

Dear Sir,

How can I set default current timestmp in mySQL? I want to have current timestamp in that field when the record is modilfied

I used below code but got error as below AddDefaultValue( model_name='my_model', name='my_column', value='NOW' ),

File "C:\Python310\lib\site-packages\MySQLdb\connections.py", line 254, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1067, "Invalid default value for 'my_column'")

Regards, Oil