use*_*364 8 python django postgresql
我将我的模型字段从Charfiled()更改为GenericIPAddressField()
ip = models.GenericIPAddressField()
Run Code Online (Sandbox Code Playgroud)
并使用django 1.7迁移
./manage.py makemigrations core
./manage.py migrate
Run Code Online (Sandbox Code Playgroud)
但是有错误:
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.
Run Code Online (Sandbox Code Playgroud)
我试试这个,但不行:
ALTER TABLE core_message ALTER COLUMN ip TYPE inet USING (ip::inet);
Run Code Online (Sandbox Code Playgroud)
错误:
ERROR: invalid input syntax for type inet: ""
Run Code Online (Sandbox Code Playgroud)
我现在能做什么?
请帮帮我谢谢!
一个快速解决方法是删除并创建字段:
ipip使用新字段类型返回/取消注释该字段我在生产中这样做,并使用先前的csv备份和几行代码的python脚本恢复数据.
| 归档时间: |
|
| 查看次数: |
3524 次 |
| 最近记录: |