Skip to main content

Django admin list view search autocomplete with related field support

Project description

Django Listview Search Admin Autocomplete

https://raw.githubusercontent.com/linevych/django-search-admin-autocomplete/master/doc/demo.gif

This is a fork of django-search-admin-autocomplete (archived). The original package is no longer maintained. This fork adds new features, modern Django support, and bug fixes.

Simple Django app that adds autocomplete search to the admin panel changelist view.

What’s New

  • Related field search: Search across ForeignKey relations (e.g., client__name, category__title)

  • List filter mode (default): Autocomplete selection filters the changelist instead of redirecting to detail

  • Django 4+ / 5+ support: Fixed deprecated url() imports

  • Modern build system: pyproject.toml with hatchling (no more setup.py)

  • Python 3.8–3.13 support

  • Comprehensive test suite (18 tests)

Requirements

  • Python: 3.8+

  • Django: 3.2+

Installation

pip install django-listview-search-admin-autocomplete
INSTALLED_APPS = [
    ...
    'search_admin_autocomplete',
    ...
]

Usage

Basic usage with direct fields:

from search_admin_autocomplete.admin import SearchAutoCompleteAdmin

class MyModelAdmin(SearchAutoCompleteAdmin):
    search_fields = ['name', 'description']

admin.site.register(MyModel, MyModelAdmin)

Configuration Options

class MyModelAdmin(SearchAutoCompleteAdmin):
    search_fields = ['name', 'client__name']
    search_prefix = '__icontains'       # Search operator (default: '__contains')
    max_results = 20                    # Max autocomplete results (default: 10)
    redirect_to_detail = True           # True: go to detail page, False: filter list (default: False)

Behavior Modes

Filter list view (default):

class MyModelAdmin(SearchAutoCompleteAdmin):
    search_fields = ['name', 'client__name']
    # redirect_to_detail = False  # default

User selects from autocomplete → search form submits → changelist filters results (same as native Django search).

Redirect to detail page:

class MyModelAdmin(SearchAutoCompleteAdmin):
    search_fields = ['name', 'client__name']
    redirect_to_detail = True

User selects from autocomplete → redirects to the object’s change/detail page.

Customization

If you have a custom change_list.html:

admin.py

from search_admin_autocomplete.admin import SearchAutoCompleteAdmin

class MyModelAdmin(SearchAutoCompleteAdmin):
    change_list_template = 'admin/custom-list.html'
    search_fields = ['name', 'client__title']

admin.site.register(MyModel, MyModelAdmin)

admin/custom-list.html

{% extends 'search_admin_autocomplete/change_list.html' %}

{% block object-tools %}
Your custom html...
{{ block.super }}
{% endblock %}

Running Tests

cd example
python manage.py test search_admin_autocomplete

Changelog

1.1.0 (2026)

  • Add redirect_to_detail option (default: False)

  • Default behavior now filters changelist like native Django search

  • Set redirect_to_detail = True for old detail-page redirect behavior

1.0.0 (2026)

  • Forked from archived django-search-admin-autocomplete

  • Added support for related field lookups (e.g., client__name)

  • Updated for Django 4+ and 5+ compatibility

  • Modernized package configuration with pyproject.toml

  • Added comprehensive test suite (18 tests)

  • Production-ready release

0.2.1 and earlier

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_listview_search_admin_autocomplete-1.1.0.tar.gz.

File metadata

File hashes

Hashes for django_listview_search_admin_autocomplete-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9901d7b4d12e8ebe72e92fe19dbb3b948d1d7326b3d6f6baeeb281a0fe24af33
MD5 cadae8f01d2922ce0ae0e4b576a41175
BLAKE2b-256 8233dc7552dc86a300e3cf7aea8c2c15222964eff375667bb77e7d29b538e999

See more details on using hashes here.

File details

Details for the file django_listview_search_admin_autocomplete-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_listview_search_admin_autocomplete-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b849063b864ea08352774ed57ec49d58b8d0236c617084d710d58ac803bf422
MD5 f58c8f71b00477e8cdbd87709df3fbcf
BLAKE2b-256 22bd2cf9e2756885ab0157dde5397506bb264adbd36d674e47b84516bf0b8e17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page