Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julianwachholz/django-autocompletefilter
Django 2.0+ ModelAdmin list_filter with autocomplete widget.
https://github.com/julianwachholz/django-autocompletefilter
autocomplete django django-admin python
Last synced: 5 days ago
JSON representation
Django 2.0+ ModelAdmin list_filter with autocomplete widget.
- Host: GitHub
- URL: https://github.com/julianwachholz/django-autocompletefilter
- Owner: julianwachholz
- License: mit
- Created: 2018-06-26T07:55:55.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T11:49:26.000Z (4 months ago)
- Last Synced: 2025-01-14T13:11:38.769Z (12 days ago)
- Topics: autocomplete, django, django-admin, python
- Language: Python
- Homepage: https://twitter.com/julianwachholz/status/1011542175358873600
- Size: 18.6 KB
- Stars: 27
- Watchers: 4
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
django-autocompletefilter
=========================A django application that lets you use the built in autocomplete function of the
django admin to filter in admin list views by foreign key relations... image:: https://pbs.twimg.com/media/DgmzYLbW4AA9oL3.jpg:large
Usage
-----#. Install the package, for example from PyPi::
pip install django-autocompletefilter
#. Add ``autocompletefilter`` to your ``INSTALLED_APPS`` setting.
#. Create and register a model admin for the model you want to filter by.
Ensure it has ``search_fields`` specified for autocomplete to work.#. In your second model admin, use the ``AutocompleteFilterMixin`` on your class and
add the desired foreign key attribute to filter by to the ``list_filter``
items by using the AutocompleteListFilter class::from autocompletefilter.admin import AutocompleteFilterMixin
from autocompletefilter.filters import AutocompleteListFilterclass FooAdmin(AutocompleteFilterMixin, admin.ModelAdmin):
list_filter = (
('bar', AutocompleteListFilter),
)Status of this project
----------------------This project is currently using a rather hacky way to implement this.
Caution is advised when using it.Using multiple autocomplete filters on the same page does work.
Currently only tested on Python 3.6
Contributing
------------All suggestions are welcome. Especially about ways to make this cleaner.
Common issues
-------------- **Reverse for '__autocomplete' not found.**
You must register a model admin with ``search_fields`` for the model you want to look up.
- **The results could not be loaded.**
You likely forgot to specify ``search_fields`` on your model admin for the model you want to look up.