Reputation: 5597
I'm trying to migrate my Django project from using sqlite3 to using PostgreSQL. I've created the database for the project, but when I try to run syncdb
, I get the following error:
django.db.utils.ProgrammingError: column "partial_value" cannot be cast automatically to type double precision
HINT: Specify a USING expression to perform the conversion.
The column is defined like this in the model:
partial_value = models.FloatField()
I tried searching for similar questions, but they seemed to be more about replacing field types.
Upvotes: 1
Views: 3803
Reputation: 5597
I found the reason to why the field was applied as character varying
in the first place. It turns out there was a migration file that defined it that way. The error was fixed by removing the migration file and running manage.py syncdb
.
Upvotes: 0
Reputation: 3860
You needs to update the type of column for 'partial_value' column. Place name of table in following code for table_name
ALTER TABLE table_name ALTER COLUMN partial_value TYPE double precision USING (trim(partial_value)::double precision);
Upvotes: 1