Skip to main content

Django Admin Autocomplete

A Django package that adds autocomplete functionality to the Django admin search bar. It provides a seamless way to search through your models in the admin interface with real-time suggestions.

Features

  • Real-time search suggestions in Django admin
  • Keyboard navigation support (arrow keys, enter, escape)
  • Customizable minimum characters for search
  • Supports multiple search fields
  • Modern and responsive design
  • Easy integration with existing Django admin

Installation

pip install django-admin-autocomplete

Quick Start

  1. Add admin_autocomplete to your INSTALLED_APPS:
INSTALLED_APPS = [
    'django.contrib.admin',
    ...
    'admin_autocomplete',
]
  1. Use the AutocompleteAdminMixin in your ModelAdmin:
from django.contrib import admin
from admin_autocomplete.admin import AutocompleteAdminMixin
from .models import YourModel

@admin.register(YourModel)
class YourModelAdmin(AutocompleteAdminMixin, admin.ModelAdmin):
    search_fields = ['title', 'description']  # Fields to search

Configuration

You can customize the autocomplete behavior in your Django settings:

ADMIN_AUTOCOMPLETE = {
    'MIN_CHARS': 2,  # Minimum characters before showing suggestions
    'MAX_RESULTS': 10,  # Maximum number of suggestions to show
}

Example

Here's a complete example using a Book model:

# models.py
from django.db import models

class Book(models.Model):
    title = models.CharField(max_length=200)
    author = models.CharField(max_length=100)
    description = models.TextField()
    published_date = models.DateField()
    isbn = models.CharField(max_length=13)

    def __str__(self):
        return f"{self.title} by {self.author}"

# admin.py
from django.contrib import admin
from admin_autocomplete.admin import AutocompleteAdminMixin
from .models import Book

@admin.register(Book)
class BookAdmin(AutocompleteAdminMixin, admin.ModelAdmin):
    search_fields = ['title', 'author', 'isbn']

Running Tests

The package includes comprehensive tests, including end-to-end tests using Selenium. To run the tests:

# Install test dependencies
pip install -e ".[dev]"

# Run tests
python manage.py test admin_autocomplete.tests

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for django-admin-autocomplete 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-autocomplete 0.2.1
File Size Uploaded Provenance
django_admin_autocomplete-0.2.1.tar.gz 14.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-autocomplete 0.2.1
File Interpreter ABI Platform
django_admin_autocomplete-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / django_admin_autocomplete-0.2.1.tar.gz

Download URL django_admin_autocomplete-0.2.1.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
508c50f28ac420ca417c56bf9c972d0eabe7ad4cc60ed7604c8ffc00707c86ef
BLAKE2b-256 checksum
How to use checksums
655b338fcef6b12bf25a3dd4616854493b8ac1518df9a638705d3afdc545b1de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/23.4.0

Release files / django_admin_autocomplete-0.2.1-py3-none-any.whl

Download URL django_admin_autocomplete-0.2.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b05afdffea07598381ae93d94261ad74a1cbca81bcc7f5d2f3a7e326151de64
BLAKE2b-256 checksum
How to use checksums
a48cea722383937f068fc3b247c384295ae17cfc87e5acdbec7f4f3779ac30c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/23.4.0

Security for django-admin-autocomplete 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page