Autocomplete filter for Grappelli
v 0.2.1 (usable, but only if you know why)
Filter for Foreign key and ManyToMany relations with AJAX autocomplete. Reuses features from Grappelli, works nicely along other filters and with both standard and sidebar filter template...
Put grappelli-filters in your PYTHONPATH.
Add 'grappelli_filters' to INSTALLED_APPS
This filter is similar to a regular foreign key field filter, with two differences:
- it has a nice AJAX-powered autocomplete UI (straight from Grappelli)
- does not load all possible filter values in HTML - good for situations with many of related objects
Configure Grappelli autocomplete feature as described here. Both Model method and SETTINGS value will work fine. For the inpatient, here is the SETTINGS value:
GRAPPELLI_AUTOCOMPLETE_SEARCH_FIELDS = {
"myapp": {
"mycategory": ("id__iexact", "name__icontains",),
}
}
In admin.py add:
from grappelli_filters import RelatedAutocompleteFilter, FiltersMixin
class MyModelAdmin(FiltersMixin, admin.ModelAdmin):
list_filter = ( ... ('field_name', RelatedAutocompleteFilter), ... )
This filter allows string searches over a single field. Several filters combined provide better control over the resulting list then does the built-in django-admin search_fields feature.
In admin.py add:
from grappelli_filters SearchFilter
class MyModelAdmin(admin.ModelAdmin):
list_filter = ( ... ('field_name', SearchFilter), ... )
Similar to Search Filter, but searches are case-sensitive.
Use SearchFilterC instead of SearchFilter
