My tables are specified as models in Python, which are then made into MySQL tables by Django. In Python:
class my_table(models.Model):
is_correct = models.IntegerField(default = 0)
If I do an insert into this table then I want it to automatically insert 0 for the column is_correct unless I specify a different value. I also want this to happen if I am using raw sql or if I am inserting from a MySQL stored procedure.
The default argument only seems to work from within Python. It’s not translated into anything that MySQL sees. Is such a thing possible?
Yes,
defaultargument works on django level. If you want to move it tomysql, performALTER TABLE ...query manually.You also can try to extend
models.IntegerFieldand overridedb_type. But it should be done for every field…