# 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
```bash
pip install django-admin-autocomplete
```
## Quick Start
1. Add `admin_autocomplete` to your `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
'django.contrib.admin',
...
'admin_autocomplete',
]
```
2. Use the `AutocompleteAdminMixin` in your ModelAdmin:
```python
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:
```python
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:
```python
# 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:
```bash
# 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/drorsoft/django_charfield_autocomplete",
"name": "django-admin-autocomplete",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "django, admin, autocomplete, search, filter",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/65/5b/338fcef6b12bf25a3dd4616854493b8ac1518df9a638705d3afdc545b1de/django_admin_autocomplete-0.2.1.tar.gz",
"platform": null,
"description": "# Django Admin Autocomplete\n\nA 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.\n\n## Features\n\n- Real-time search suggestions in Django admin\n- Keyboard navigation support (arrow keys, enter, escape)\n- Customizable minimum characters for search\n- Supports multiple search fields\n- Modern and responsive design\n- Easy integration with existing Django admin\n\n## Installation\n\n```bash\npip install django-admin-autocomplete\n```\n\n## Quick Start\n\n1. Add `admin_autocomplete` to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n 'django.contrib.admin',\n ...\n 'admin_autocomplete',\n]\n```\n\n2. Use the `AutocompleteAdminMixin` in your ModelAdmin:\n\n```python\nfrom django.contrib import admin\nfrom admin_autocomplete.admin import AutocompleteAdminMixin\nfrom .models import YourModel\n\n@admin.register(YourModel)\nclass YourModelAdmin(AutocompleteAdminMixin, admin.ModelAdmin):\n search_fields = ['title', 'description'] # Fields to search\n```\n\n## Configuration\n\nYou can customize the autocomplete behavior in your Django settings:\n\n```python\nADMIN_AUTOCOMPLETE = {\n 'MIN_CHARS': 2, # Minimum characters before showing suggestions\n 'MAX_RESULTS': 10, # Maximum number of suggestions to show\n}\n```\n\n## Example\n\nHere's a complete example using a Book model:\n\n```python\n# models.py\nfrom django.db import models\n\nclass Book(models.Model):\n title = models.CharField(max_length=200)\n author = models.CharField(max_length=100)\n description = models.TextField()\n published_date = models.DateField()\n isbn = models.CharField(max_length=13)\n\n def __str__(self):\n return f\"{self.title} by {self.author}\"\n\n# admin.py\nfrom django.contrib import admin\nfrom admin_autocomplete.admin import AutocompleteAdminMixin\nfrom .models import Book\n\n@admin.register(Book)\nclass BookAdmin(AutocompleteAdminMixin, admin.ModelAdmin):\n search_fields = ['title', 'author', 'isbn']\n```\n\n## Running Tests\n\nThe package includes comprehensive tests, including end-to-end tests using Selenium. To run the tests:\n\n```bash\n# Install test dependencies\npip install -e \".[dev]\"\n\n# Run tests\npython manage.py test admin_autocomplete.tests\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Django library that adds autocomplete functionality to the admin search bar",
"version": "0.2.1",
"project_urls": {
"Documentation": "https://github.com/drorsoft/django_charfield_autocomplete",
"Homepage": "https://github.com/drorsoft/django_charfield_autocomplete",
"Repository": "https://github.com/drorsoft/django_charfield_autocomplete"
},
"split_keywords": [
"django",
" admin",
" autocomplete",
" search",
" filter"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a48cea722383937f068fc3b247c384295ae17cfc87e5acdbec7f4f3779ac30c8",
"md5": "49684fdac966941c8eb833ced4cebdfd",
"sha256": "0b05afdffea07598381ae93d94261ad74a1cbca81bcc7f5d2f3a7e326151de64"
},
"downloads": -1,
"filename": "django_admin_autocomplete-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "49684fdac966941c8eb833ced4cebdfd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 10971,
"upload_time": "2024-11-26T18:10:51",
"upload_time_iso_8601": "2024-11-26T18:10:51.059788Z",
"url": "https://files.pythonhosted.org/packages/a4/8c/ea722383937f068fc3b247c384295ae17cfc87e5acdbec7f4f3779ac30c8/django_admin_autocomplete-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "655b338fcef6b12bf25a3dd4616854493b8ac1518df9a638705d3afdc545b1de",
"md5": "7d7eb70fae009a5ab14020594a85c876",
"sha256": "508c50f28ac420ca417c56bf9c972d0eabe7ad4cc60ed7604c8ffc00707c86ef"
},
"downloads": -1,
"filename": "django_admin_autocomplete-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "7d7eb70fae009a5ab14020594a85c876",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 14716,
"upload_time": "2024-11-26T18:10:52",
"upload_time_iso_8601": "2024-11-26T18:10:52.697631Z",
"url": "https://files.pythonhosted.org/packages/65/5b/338fcef6b12bf25a3dd4616854493b8ac1518df9a638705d3afdc545b1de/django_admin_autocomplete-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 18:10:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "drorsoft",
"github_project": "django_charfield_autocomplete",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-admin-autocomplete"
}