django-geo là một ứng dụng Django mà quản lý dữ liệu địa lý hành chính. Nó sử dụng thay đổi preorder Tree Traversal, được cung cấp bởi django-mptt https://github.com/django-mptt/django-mptt/
Geo không intented để thay thế một GIS, nhưng để quản lý tất cả các trường hợp, nơi bạn có cây hành chính, với một hệ thống cấp bậc nghiêm ngặt / lười biếng.
Mô hình
- Country
- Diện tích
- Vị trí
- AdministrativeAreaType
- Tiền tệ
Ví dụ
& Nbsp; Ba mức độ
& Nbsp; italy = Country.objects.get (iso_code = 'CNTT')
& Nbsp; regione, __ = italy.administrativeareatype_set.get_or_create (name = 'Regione')
& Nbsp; provincia, __ = italy.administrativeareatype_set.get_or_create (name = 'Provincia',
& Nbsp; mẹ = regione)
& Nbsp; đô thị, __ = italy.administrativeareatype_set.get_or_create (name = 'Comune',
& Nbsp; mẹ = provincia)
& Nbsp; Lazio, __ = AdministrativeArea.objects.get_or_create (nước = italy,
& Nbsp; name = 'Lazio,
& Nbsp; type = regione)
& Nbsp; roma_provincia, __ = AdministrativeArea.objects.get_or_create (nước = italy,
& Nbsp; name = 'Provincia di Roma,
& Nbsp; type = provincia,
& Nbsp; mẹ = Lazio)
& Nbsp; roma_comune, __ = AdministrativeArea.objects.get_or_create (nước = italy,
& Nbsp; name = 'Comune di Roma,
& Nbsp; type = đô thị,
& Nbsp; mẹ = roma_provincia)
& Nbsp; roma, __ = Location.objects.get_or_create (nước = italy,
& Nbsp; name = 'Roma,
& Nbsp; type = Location.CITY,
& Nbsp; diện tích = roma_comune)
& Nbsp; Hai cấp độ,
& Nbsp; chúng tôi = Country.objects.get (iso_code = 'Mỹ')
& Nbsp; nhà nước, __ = italy.administrativeareatype_set.get_or_create (name = 'nhà nước')
& Nbsp; quận, __ = italy.administrativeareatype_set.get_or_create (name = 'County,
& Nbsp; mẹ = nhà nước)
& Nbsp; ny, __ = AdministrativeArea.objects.get_or_create (nước = chúng tôi,
& Nbsp; name = 'New York',
& Nbsp; type = nhà nước)
& Nbsp; columbia, __ = AdministrativeArea.objects.get_or_create (nước = chúng tôi,
& Nbsp; name = 'Columbia,
& Nbsp; type = quận,
& Nbsp; mẹ = ny)
& Nbsp; hudson, __ = Location.objects.get_or_create (nước = chúng tôi,
& Nbsp; name = 'Hudson,
& Nbsp; type = Location.CITY,
& Nbsp; diện tích = columbia,
& Nbsp; is_administrative = True)
Yêu cầu :
- Python
- Django
Bình luận không