Skip to content

Commit

Permalink
Merge pull request #7 from catalpainternational/fix_admin_autocomplete
Browse files Browse the repository at this point in the history
Fix admin autocomplete
  • Loading branch information
PeteCoward authored Jun 28, 2018
2 parents 9d594ba + 363bf02 commit eb3ac26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
14 changes: 12 additions & 2 deletions simple_locations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit eb3ac26

Please sign in to comment.