Skip to main content
https://badge.fury.io/py/django-admin-autocomplete-all.svg https://travis-ci.org/pyutil/django-admin-autocomplete-all.svg?branch=master https://codecov.io/gh/pyutil/django-admin-autocomplete-all/branch/master/graph/badge.svg

3 different things in Django Admin:

  1. Use select2 (autocomplete_fields) everywhere (because implicit is better than explicit).

  2. Get more context for filtering in get_search_results

  3. Hide danger delete/edit buttons near to the ForeignKey popups

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 want enhanced get_search_results filtering.)

Features

  1. Use select2 (autocomplete_fields) everywhere.

No need to change INSTALLED_APPS to achieve this. In your admin.py do import autocomplete_all as admin.

import autocomplete_all as admin
class MyModelAdmin(admin.ModelAdmin):
    ....

Alternatively import ModelAdmin, StackedInline and/or TabularInline ‘from autocomplete_all’ instead of ‘from admin’.

import autocomplete_all
class MyModelAdmin(autocomplete_all.ModelAdmin):
    ....

You will then need implement lot of search_fields=.. settings in related ModelAdmins. You can try start (ie. runserver) without adding search_fields and Django will show you what is required.

  1. Get more context in get_search_results.

Standard Django autocomplete_fields cannot inside get_search_results distinguish between the ForeignKey which asks for the queryset, especially if 2 ForeignKey’s from single model target into same model (often example: ForeignKey into User model). If you add this package (‘autocomplete_all’) into INSTALLED_APPS, then ?key=… will be added into url. Inside get_search_results you will have access to: application, model, ForeignKey. See example in static/autocomplete_all/js/autocomplete_params.js.

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

  1. Hide danger buttons in Admin ChangeForm.

The edit & delete buttons near the ForeignKey have very difficult and danger logic what they will do. If you add autocomplete_all in INSTALLED_APPS before django.contrib.admin (or some application which replaces admin design, like django-baton), then the danger buttons will disapear. Place the autocomplete_all “lower” in list if you don’t want this effect.

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.3.0 (2021-03-03)

  • if used in INSTALLED_APPS before django.contrib.admin (or admin rewriting app), danger ForeignKey buttons (edit,delete) will disapear

  • import admin methods (example: .register): in many cases you can just import autocomplete_all as admin and no more changes in admin.py are needed

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.

Metadata

Release files for django-admin-autocomplete-all 0.3.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-all 0.3.1
File Size Uploaded Provenance Actions
django-admin-autocomplete-all-0.3.1.tar.gz 11.5 kB Without provenance Details for django-admin-autocomplete-all-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-autocomplete-all 0.3.1
File Interpreter ABI Platform Actions
django_admin_autocomplete_all-0.3.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_admin_autocomplete_all-0.3.1-py2.py3-none-any.whl

Total release size: 20.2 kB

Release files / django-admin-autocomplete-all-0.3.1.tar.gz

Download URL django-admin-autocomplete-all-0.3.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0afa35d779b5545b180a511603edd9b7b234654a5a7dd26d5c92ec4c347d7a7d
BLAKE2b-256 checksum
How to use checksums
46ab1f5e46e11b94c095e50ca2b7a62683cc470674bdfbb678551e82969d1b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Release files / django_admin_autocomplete_all-0.3.1-py2.py3-none-any.whl

Download URL django_admin_autocomplete_all-0.3.1-py2.py3-none-any.whl
Size 8.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ce729d3c07084db07b968d6a8493a92b3626a17160d70e8782c741f703cf840d
BLAKE2b-256 checksum
How to use checksums
5c37388d012479092e5e6dc72bb83feb3f9bc61efffe09fa759cb2d821720bc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

Security for django-admin-autocomplete-all 0.3.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