Django inserting the string "(NULL)" to MySQL fields for Null instead of NULL -
i'm trying use 2 character field nullable address table in mysql. when run manage.py syncdb command, loads data mysql table, yields error:
file "c:\python27\lib\site-packages\mysqldb\connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue databaseerror: (1406, "data long column 'state_province' @ row 1")
i found issue django inserting table string "(null)" instead of null value sql.
the field in question "state_province" null=true, blank=true in model definition, length of 2.
here sample set of data:
- model: myapp.address pk: 53 fields: street_address: "71 south st" city: cityname state_province: zip_code: 25455 countryid: 199 time_zone: -6 - model: myapp.address pk: 54 fields: street_address: "123 lake street" city: townname state_province: nh zip_code: 12345 countryid: 199 time_zone: -5
edit: forgot link, question happening, don't know how correct behavior in django, or start: inserting null char(1)
well, may sound harsh, core , high profile part of django's inner workings. if bug in django, well-documented and, more importantly, fixed already.
since you're experiencing error manage.py , not own code, though, best guess field not set allow null on mysql table, , django trying compensate best can.
check mysql table , ensure null allowed on state_province
column.
Comments
Post a Comment