coderholic / django-cities

Countries and cities of the world for Django projects
MIT License
913 stars 377 forks source link

How can I get only the boroughs of a city without the districts? #207

Open sowinski opened 5 years ago

sowinski commented 5 years ago

Hi,

is it possible to get only the boroughs of a city?

Example: berlin = City.objects.filter(name="Berlin")[0] len(District.objects.filter(city=berlin)) This should be 12 but gives me 205 because it includes boroughs and districts. https://en.wikipedia.org/wiki/Boroughs_and_neighborhoods_of_Berlin

Thank you :)

sowinski commented 5 years ago

I was investigating where the problem is. On geoames.org you can see those informations and there are also in the files which you can download.

Example: http://www.geonames.org/7118093/gallus.html

"Innenstadt I" is not listes as a district, only "Gallus". Why is this hierarchy not stored and how can I fix this?

Thx :)

sowinski commented 5 years ago

In the config there is this line of code for district types: district_types = ['PPLX'] I have seen that the parents of PPLX is ADM5. I would like to include both.

But how can I later see the difference between those two kinds?

I guess there should also be a type field for districts.