Package: django-admin-autocomplete-list-filter
django-admin-autocomplete-list-filterAjax autocomplete list filter helper for Django admin. Uses Django’s built-in
autocomplete widget! No extra package or install required!UpdateDropped support for Django 2 family. Works withDjango 3or higher!.masterbranch is renamed tomain... You can fix your existing clones via;gitbranch-mmastermain
gitfetchorigin
gitbranch-uorigin/mainmain
gitremoteset-headorigin-aInstallation and Usage$pipinstalldjango-admin-autocomplete-list-filterAdddjaa_list_filtertoINSTALLED_APPSin yoursettings.py:INSTALLED_APPS=['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','djaa_list_filter',]Now, let’s look at this example model:# models.pyfromdjango.confimportsettingsfromdjango.dbimportmodelsclassPost(models.Model):category=models.ForeignKey(to='Category',on_delete=models.CASCADE,related_name='posts')author=models.ForeignKey(to=settings.AUTH_USER_MODEL,on_delete=models.CASCADE,related_name='posts')title=models.CharField(max_length=255)body=models.TextField()tags=models.ManyToManyField(to='Tag',blank=True)def__str__(self):returnself.titleclassCategory(models.Model):title=models.CharField(max_length=255)def__str__(self):returnself.titleclassTag(models.Model):name=models.CharField(max_length=255)def__str__(self):returnself.nameWe have 2ForeignKeyfields and oneManyToManyFieldto enable
autocomplete list filter feature on admin. All you need is to inherit fromAjaxAutocompleteListFilterModelAdminwhich inherits from Django’sadmin.ModelAdmin.Now we have an extra ModelAdmin method:autocomplete_list_filter. Uses
Django Admin’ssearch_fieldslogic. You need to enablesearch_fieldsin the related ModelAdmin. To enable completion onCategoryrelation,CategoryAdminshould havesearch_fieldsthat’s it!fromdjango.contribimportadminfromdjaa_list_filter.adminimport(AjaxAutocompleteListFilterModelAdmin,)from.modelsimportCategory,Post,Tag@admin.register(Post)classPostAdmin(AjaxAutocompleteListFilterModelAdmin):list_display=('__str__','author','show_tags')autocomplete_list_filter=('category','author','tags')defshow_tags(self,obj):return' , '.join(obj.tags.values_list('name',flat=True))@admin.register(Category)classCategoryAdmin(admin.ModelAdmin):search_fields=['title']ordering=['title']@admin.register(Tag)classTagAdmin(admin.ModelAdmin):search_fields=['name']ordering=['name']DevelopmentYou are very welcome to contribute, fix bugs or improve this project. We
hope to help people who needs this feature. We made this package for
our company project. Good appetite for all the Django developers out there!LicenseThis project is licensed under MITContributor(s)Uğur "vigo" Özyılmazel- Author, MaintainerCan Adıyaman- Author, MaintainerErdi Mollahüseyinoğlu- Author, MaintainerGuglielmo Celata- ContributorJoseph Bane- ContributorRyohei Endo- ContributorPeter Farrell- ContributorMárton Salomváry- ContributorContributeAll PR’s are welcome!fork(https://github.com/demiroren-teknoloji/django-admin-autocomplete-list-filter/fork)Create yourbranch(git checkout -b my-features)commityours (git commit -am 'added killer options')pushyourbranch(git push origin my-features)Than create a newPull Request!TODOAdd unit testsImprove JavaScript code :)Change Log2021-08-17Fix Django 3 compatibility changesAllow for more than one autocomplete fieldstaticfiles fixmasterbranch is renamed tomain2019-10-25Remove f-string for older Python versions, will change this on 1.0.0 version2019-10-19Bump version: 0.1.2Add Python 3.5 supports, thanks toPeter FarrelAdd animated gif :)Add future warning for f-strings2019-10-11Add ManyToManyField supportInitial release2019-10-07Init repo...