python - django migrate has error: Specify a USING expression to perform the conversion -


i change model field charfiled() genericipaddressfield()

ip = models.genericipaddressfield() 

and use django 1.7 migrate

./manage.py makemigrations core ./manage.py migrate 

but there error:

return self.cursor.execute(sql, params) django.db.utils.programmingerror: column "ip" cannot cast automatically type inet hint:  specify using expression perform conversion. 

i try this,but not work:

alter table core_message alter column ip type inet using (ip::inet); 

error:

error:  invalid input syntax type inet: "" 

what can now?
please me thank you!

one quick fix drop , create field:

  1. delete migration changing field type.
  2. delete/comment field ip
  3. make migrations
  4. get back/uncomment field ip new field type
  5. make migrations
  6. migrate

i did in production , restored data previous csv backup , python script of few lines code.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -