Reputation: 6713
I change my model field from Charfiled() to GenericIPAddressField()
ip = models.GenericIPAddressField()
and use django 1.7 migrate
./manage.py makemigrations core
./manage.py migrate
But there is error:
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "ip" cannot be cast automatically to type inet
HINT: Specify a USING expression to perform the conversion.
I try this,but not work:
ALTER TABLE core_message ALTER COLUMN ip TYPE inet USING (ip::inet);
error:
ERROR: invalid input syntax for type inet: ""
What can I do now?
Please help me Thank you!
Upvotes: 8
Views: 3664
Reputation: 11932
one quick fix will be to drop and create the field:
ip
ip
with the new field typeI did this in production and restored the data with a previous csv backup and an python script of a few lines a code.
Upvotes: 9