Skip to main content

django-admin-filter-kit

Русский · English

Небольшие дополнения к фильтрам списков в админке Django:

  • AutocompleteFilter — фильтр по связанной записи с подсказками по мере набора. Для справочников, которые не помещаются в панель фильтров списком ссылок.
  • Сворачиваемая панель фильтров — щелчок по заголовку «Фильтр» прячет фильтры, и таблица занимает всю ширину. Браузер запоминает выбор для всех списков. Включено по умолчанию.
  • Курсор сразу в поле поиска, когда открываются подсказки. Select2 4.0.13, который идёт с Django, с jQuery 3.6+ фокус сам не ставит, и первая набранная буква теряется.

Зависимостей, кроме Django, нет. Поддерживаются Django 5.2, 6.0 и 6.1 на Python 3.10+.

Установка

pip install django-admin-filter-kit
INSTALLED_APPS = [
    "admin_filter_kit",  # выше django.contrib.admin
    "django.contrib.admin",
    # ...
]

Приложение должно стоять выше django.contrib.admin. Скрипты пакета подключает его собственный шаблон admin/change_list.html — он расширяет шаблон Django, а Django берёт первый найденный. Если порядок неверный, об этом предупредит проверка admin_filter_kit.W001.

Фильтр с подсказками

from django.contrib import admin

from admin_filter_kit.filters import AutocompleteFilter


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_filter = [
        ("author", AutocompleteFilter),           # ForeignKey
        ("tags", AutocompleteFilter),             # ManyToManyField
        ("author__country", AutocompleteFilter),  # через связь
    ]


@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    search_fields = ["name"]  # обязательно: подсказки ищут по этим полям

Подсказки приходят из встроенного автокомплита админки — того же, что работает у autocomplete_fields. Поэтому своих адресов у пакета нет, а правила те же:

  • у админки связанной модели должны быть search_fields;
  • подсказки видит тот, у кого есть право просмотра связанной модели; поиск и сортировка — как в её админке, учитывается limit_choices_to поля;
  • подсказки подгружаются по 20 при наборе и прокрутке, подпись записи — str(obj).

Страница списка не загружает справочник целиком — только выбранную запись, чтобы показать её название. Выбор записи перезагружает список с фильтром, × снимает фильтр. Остальные фильтры, поиск и сортировка сохраняются.

Пока не умеет: выбрать несколько записей сразу и отобрать записи без связи.

Сворачиваемая панель

Работает во всех списках админки, где есть фильтры, — код писать не нужно. Выключить:

ADMIN_FILTER_KIT_COLLAPSIBLE = False

Свои шаблоны списка

Если в проекте переопределён admin/change_list.html или у ModelAdmin задан change_list_template, этот шаблон должен расширять "admin/change_list.html" — как обычно и делают. Иначе скрипты пакета на страницу не попадут, и фильтр с подсказками не заработает.

Разработка

pip install -e .
python -m django test --settings=tests.settings

Лицензия

MIT

Metadata

Release files for django-admin-filter-kit 0.1.0

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-filter-kit 0.1.0
File Size Uploaded Provenance
django_admin_filter_kit-0.1.0.tar.gz 10.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-filter-kit 0.1.0
File Interpreter ABI Platform
django_admin_filter_kit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / django_admin_filter_kit-0.1.0.tar.gz

Download URL django_admin_filter_kit-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1ef994b00fe48cc055bc62d64ddf4916563fc35dc8542dad3bb1dc6649cf227e
BLAKE2b-256 checksum
How to use checksums
d90131f0f6d47b2a22b1fee622d41beac12c6f720d547208fd845ed14e578a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / django_admin_filter_kit-0.1.0-py3-none-any.whl

Download URL django_admin_filter_kit-0.1.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78b6789b6ff323bc1a14d1e937266480a9245da803586e56592d73db572cec4c
BLAKE2b-256 checksum
How to use checksums
d95a972557346c41872303b3e4513e4eb8c8c0ed124f59da1cf764bab0d64ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for django-admin-filter-kit 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_admin_filter_kit-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

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.

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