coderholic / django-cities

Countries and cities of the world for Django projects
MIT License
920 stars 374 forks source link

--import=PostalCode produces error. #155

Closed donnaloia closed 7 years ago

donnaloia commented 7 years ago

Hi, I am having an issue when running the following in order.

python manage.py cities --import=country --force Countries.objects.all().exclude(name='United States").delete() python manage.py cities --import=city python manage.py cities --import=postal_code


WARNING Postal code 99505 (United States) - invalid location ('', ''): could not convert string to float: 
null value in column "location" violates not-null constraint
web         | DETAIL:  Failing row contains (54, Jber, none, 99505, null, , Anchorage Municipality, , 6252001, null, null, null, null).

What is strange is I have been using Django-cities for almost two years and I have always ran a shell script with the lines above, and now for some reason it produces an error.

I have tried to reset and wipe database but still same error.

blag commented 7 years ago

Hi, contributor here. Can you answer a few questions for me:

Thanks!

blag commented 7 years ago

Digging into this a bit more, the import script seems to be tripping up here. As far as I'm aware, all Geonames postal code data contains latitude and longitude.

Double check that your data source has latitude and longitude coordinates. If you're importing from Geonames and it's missing coordinates, you can add coordinates through Geonames web interface and wait 24 hours for them to export another dump of their database.

If none of that works for you I can take a look at allowing postal code location fields to be NULL.

blag commented 7 years ago

I Googled around and USAFA JBER Hospital. I think somebody accidentally added it as a postal code which was then removed or fixed.

Either way, this is looking like a data bug, not a logic bug in this package. Closing.