migrations

Fix “django.db.utils.ProgrammingError: column cannot be cast automatically”

Error below appear when I change “CharField” in my model to “DateTimeField”.

django.db.utils.ProgrammingError: column "created_date" cannot be cast automatically to type timestamp with time zone
HINT:  Specify a USING expression to perform the conversion.

And error below when I change “CharField” in my model to “SmallIntegerField”.

django.db.utils.ProgrammingError: column "status_type" cannot be cast automatically to type smallint
HINT:  Specify a USING expression to perform the conversion.

I solved those error by commenting on field that I need to change and make new migration, so those field will deleted in my database.
After that I uncomment those fields and make migration with new field type.

If you found better solution, let me know and don’t hesitate to comment. 😀