demiroren-teknoloji
django-admin-autocomplete-list-filter
Python

Ajax autocomplete list filter for Django admin

Last updated Apr 24, 2026
83
Stars
35
Forks
5
Issues
0
Stars/day
Attention Score
15
Language breakdown
Python 67.0%
JavaScript 16.9%
Ruby 11.9%
HTML 2.9%
CSS 1.2%
Files click to expand
README

Python Python Python Python Django Code style: black PyPI version Downloads

django-admin-autocomplete-list-filter

Ajax autocomplete list filter helper for Django admin. Uses Django’s built-in autocomplete widget! No extra package or install required!

After

Update

Dropped support for Django 2 family. Works with Django 3 or higher!. master branch is renamed to main... You can fix your existing clones via;

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Installation and Usage

$ pip install django-admin-autocomplete-list-filter

Add djaalistfilter to INSTALLED_APPS in your settings.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'djaalistfilter',           
]

Now, let’s look at this example model:

# models.py

from django.conf import settings from django.db import models

class Post(models.Model): category = models.ForeignKey(to='Category', ondelete=models.CASCADE, relatedname='posts') author = models.ForeignKey(to=settings.AUTHUSERMODEL, ondelete=models.CASCADE, relatedname='posts') title = models.CharField(max_length=255) body = models.TextField() tags = models.ManyToManyField(to='Tag', blank=True)

def str(self): return self.title

class Category(models.Model): title = models.CharField(max_length=255)

def str(self): return self.title

class Tag(models.Model): name = models.CharField(max_length=255)

def str(self): return self.name

We have 2 ForeignKey fields and one ManyToManyField to enable autocomplete list filter feature on admin. All you need is to inherit from AjaxAutocompleteListFilterModelAdmin which inherits from Django’s admin.ModelAdmin.

Now we have an extra ModelAdmin method: autocompletelistfilter. Uses Django Admin’s searchfields logic. You need to enable searchfields in the related ModelAdmin. To enable completion on Category relation, CategoryAdmin should have search_fields that’s it!

from django.contrib import admin

from djaalistfilter.admin import ( AjaxAutocompleteListFilterModelAdmin, )

from .models import Category, Post, Tag

@admin.register(Post) class PostAdmin(AjaxAutocompleteListFilterModelAdmin): listdisplay = ('str', 'author', 'showtags') autocompletelistfilter = ('category', 'author', 'tags')

def show_tags(self, obj): return ' , '.join(obj.tags.values_list('name', flat=True))

@admin.register(Category) class CategoryAdmin(admin.ModelAdmin): search_fields = ['title'] ordering = ['title']

@admin.register(Tag) class TagAdmin(admin.ModelAdmin): search_fields = ['name'] ordering = ['name']

Development

You 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!

License

This project is licensed under MIT


Contributor(s)


Contribute

All PR’s are welcome!

  • fork (https://github.com/demiroren-teknoloji/django-admin-autocomplete-list-filter/fork)
  • Create your branch (git checkout -b my-features)
  • commit yours (git commit -am 'added killer options')
  • push your branch (git push origin my-features)
  • Than create a new Pull Request!

TODO

  • Add unit tests
  • Improve JavaScript code :)

Change Log

2021-08-17

2019-10-25
  • Remove f-string for older Python versions, will change this on 1.0.0 version
2019-10-19
  • Bump version: 0.1.2
  • Add Python 3.5 supports, thanks to Peter Farrel
  • Add animated gif :)
  • Add future warning for f-strings
2019-10-11
  • Add ManyToManyField support
  • Initial release
2019-10-07
  • Init repo...

© 2026 GitRepoTrend · demiroren-teknoloji/django-admin-autocomplete-list-filter · Updated daily from GitHub