django-cities icon indicating copy to clipboard operation
django-cities copied to clipboard

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

Open sowinski opened this issue 7 years ago • 2 comments
trafficstars

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 avatar Oct 11 '18 15:10 sowinski

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 avatar Oct 12 '18 08:10 sowinski

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.

sowinski avatar Oct 12 '18 08:10 sowinski