django admin: use select2 (autocomplete_fields) everywhere
Project description
Django admin: 1) Get more context for filtering in get_search_results, 2) use select2 (autocomplete_fields) everywhere (because implicit is better than explicit).
Documentation
The full documentation is at https://django-admin-autocomplete-all.readthedocs.io.
Quickstart
Install django-admin-autocomplete-all:
pip install django-admin-autocomplete-all
Add ‘autocomplete_all’ into INSTALLED_APPS, then collectstatic (both not required if you don’t play with get_search_results filtering.)
Features
Get more context in get_search_results. Implement filtering into get_search_results of target ModelAdmin and add this to the source ModelAdmin:
class MyModelAdmin(ModelAdmin): # ModelAdmin can be standard or autocomplete_all.ModelAdmin
class Media:
js = ('autocomplete_all/js/autocomplete_params.js',)
You can also implement dynamic filters based on current value of other form fields. See Usage for details or read in source code: autocomplete_all/js/autocomplete_params.js
Use select2 (autocomplete_fields) everywhere.
In your admin.py import ModelAdmin, StackedInline and/or TabularInline ‘from autocomplete_all’ instead of ‘from admin’.
import autocomplete_all
class MyModelAdmin(autocomplete_all.ModelAdmin):
....
You need implement lot of search_fields=.. settings in related ModelAdmins. You can try start (ie. runserver) without this and Django will show you what is required.
Running Tests
Does the code actually work? /N/A while we haven’t the 1st test yet./
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -r requirements_test.txt (myenv) $ tox
Credits
Tools used in rendering this package:
History
0.2.6 (2020-05-06)
Fix: added class Media to fix some scenario(s) where widget is missing
0.2.4 (2020-01-27)
gives additional context in get_search_results()
Fix: missing .js (in 0.2.0-0.2.3)
0.1.6 (2020-01-24)
Fix in docs: proper attribute name is: autocomplete_except
0.1.4 (2020-01-22)
First acceptable version.
Project details
Release history Release notifications | RSS feed
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
Hashes for django-admin-autocomplete-all-0.2.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d57be097d8c1f4a5d7662bcabf861565e9e0bc6c54536f87012812893feede3 |
|
MD5 | 5faaaf3c3436cc0a5fa3736edcd34bcb |
|
BLAKE2b-256 | 83f2387370cb82175c840a07e09db3b567ccb4e3d23ca60613003f404254568d |
Hashes for django_admin_autocomplete_all-0.2.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | effa7f182fa8784e6c223ede4e9bc22d94cf5c1f424f7b73f19dece2a41bbe6d |
|
MD5 | fcf9f751896d1c94435c53d204330e16 |
|
BLAKE2b-256 | 8c26e385ef902d68643ffea72ce579dd2d992bbbc33cf65afe1a35808aee3cc4 |