Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

vosi/django-grappelli-filters

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-grappelli-filters

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...

Screenshot

Installation

Put grappelli-filters in your PYTHONPATH.

Add 'grappelli_filters' to INSTALLED_APPS

Filters

Related Autocomplete Filter

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
Usage

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), ... )

Search Filter

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.

Usage

In admin.py add:

from grappelli_filters SearchFilter

class MyModelAdmin(admin.ModelAdmin):
    list_filter = ( ... ('field_name', SearchFilter), ... )

Case-sensitive Search Filter

Similar to Search Filter, but searches are case-sensitive.

Usage

Use SearchFilterC instead of SearchFilter

About

Autocomplete filter for Grappelli

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 37.9%
  • JavaScript 27.5%
  • HTML 26.8%
  • CSS 7.8%