diff --git a/README.md b/README.md index 7dfcab0..cac28ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +## simple_locations + +The common location package used for catalpa's projects. A hierarchical tree of geographical locations supporting location type and GIS data + +#### Changelog + + * Version 2.7.2 + - optionally use django_extensions' ForeignKeyAutocompleteAdmin in admin interface + #### Uploading a new version to PyPi * install setuptools and twine diff --git a/setup.py b/setup.py index 0ed7c3a..f528713 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='simple_locations', - version='2.7.1', + version='2.7.2', license="BSD", description="The common location package used for catalpa's projects.", diff --git a/simple_locations/admin.py b/simple_locations/admin.py index 824b3fa..5890cc9 100644 --- a/simple_locations/admin.py +++ b/simple_locations/admin.py @@ -9,6 +9,15 @@ from simple_locations.models import Point, AreaType, Area +try: + # optionally use django_extensions' ForeignKeyAutocompleteAdmin if available + from django_extensions.admin import ForeignKeyAutocompleteAdmin + class MPTTModelAutocompleteAdmin(MPTTModelAdmin, ForeignKeyAutocompleteAdmin): + pass +except ImportError: + class MPTTModelAutocompleteAdmin(MPTTModelAdmin): + pass + class PointAdmin(admin.ModelAdmin): list_display = ('id', 'latitude', 'longitude') @@ -18,11 +27,12 @@ class AreaTypeAdmin(admin.ModelAdmin): list_display = ('slug', 'name') -class AreaAdmin(MPTTModelAdmin): +class AreaAdmin(MPTTModelAutocompleteAdmin): list_display = ( 'name', 'kind', 'location', 'code') search_fields = ['code', 'name'] list_filter = ('kind',) - + related_search_fields = {'parent': ('^name',)} + admin.site.register(Point, PointAdmin) admin.site.register(AreaType, AreaTypeAdmin)