2021年1月17日星期日

django.db.utils.OperationalError 1101. JSON column can't have a default value

I was fiddling around with Django forms and CKEditor when I realised that my forms weren't valid after changing from django's default longtext widget to CK's RichText widget. To try to work around this, idky but I tried changing the model so that the field is nullable:

field=models.TextField(blank=True, null=True),  

This caused me some problems so I tried reverting back:

field=models.TextField(blank=True),  

There was a prompt to fill in a null or something: "Ignore for now, and let me handle existing rows with NULL myself". I carelessly used that option and this has caused a whole host of problems and I can't even rollback to a previous migration anymore.

I tried altering the tables manually to set them back to null=False but it didn't solve the problem. I saw something online and tried to alter the table to set default to ("{}") but the command couldn't run due to the same-titled error. I was unsure too, so I filled up all the empty fields of the column in the actual data with "-" so that it isn't empty or null. These methods have not worked so far.

Thank you!

https://stackoverflow.com/questions/65730315/django-db-utils-operationalerror-1101-json-column-cant-have-a-default-value January 15, 2021 at 11:57AM

没有评论:

发表评论