Admin Django Helpers
Полезные помощники и утилиты для Django Admin с поддержкой глобального поиска.
🚀 Возможности
- Глобальный поиск: Легко добавьте функциональность глобального поиска в Django Admin
- Миксины для моделей: Удобные миксины для расширения функциональности моделей
- Готовые действия: Полезные действия для админ-панели
- Контекстные процессоры: Дополнительные контекстные процессоры для шаблонов
- Шаблонные теги: Набор полезных шаблонных тегов
📦 Установка
pip install admin-dj-helpers
⚙️ Быстрый старт
1. Добавьте приложение в settings.py
INSTALLED_APPS = [
'admin_dj_helpers', # обязательно первым в перед django.contrib.admin
'admin_dj_helpers.global_search', # Для добавления глобального поиска
'admin_dj_helpers.actions', # Для добавления действий
'django.admin.contrib',
'...',
]
2. Используйте GlobalSearchMixin в ваших моделях
from django.db import models
from admin_helpers.global_search.mixin import GlobalSearchMixin
class Article(GlobalSearchMixin, models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
author = models.CharField(max_length=100)
# Настройка глобального поиска
search_icon = 'fa-solid fa-newspaper'
search_description = 'Статьи сайта'
@classmethod
def get_global_search_fields(cls, query_string: str):
return [
'title',
'content',
'author'
]
def __str__(self):
return self.title
3. Настройте контекстные процессоры
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'admin_helpers.context_processors.settings', # Обязателен для работы поиска и действий
],
},
},
]
📚 Подробная документация
GlobalSearchMixin
Миксин для добавления поддержки глобального поиска к вашим моделям.
Настройки класса:
search_icon- иконка для отображения в результатах поиска (FontAwesome)search_description- описание модели для поискаsearch_order_by- поле для сортировки результатовorder_in_search- порядок отображения в результатах
Обязательные методы:
@classmethod
def get_global_search_fields(cls, query_string: str) -> List[str]:
""" Возвращает список полей для поиска """
return ['field1', 'field2']
Опциональные методы:
@classmethod
def get_search_item(cls, obj, request) -> Dict[str, str]:
""" Кастомизация элемента в результатах поиска """
return {
'type': 'model',
'icon': cls.search_icon,
'title': str(obj),
'description': repr(obj),
'url': None,
'model_name': cls._meta.verbose_name
}
🔧 Требования
- Python >= 3.9
- Django >= 3.2
🤝 Поддерживаемые версии Django
- Django 3.2+
- Django 4.0+
- Django 4.1+
- Django 4.2+
- Django 5.0+
- Django 5.1+
📄 Лицензия
MIT License. Подробности в файле LICENSE.
🐛 Сообщить об ошибке
Если вы нашли ошибку или у вас есть предложения по улучшению, пожалуйста, создайте issue в GitHub репозитории.
📊 Статус разработки
Проект находится в стадии активной разработки (Alpha). API может изменяться.
Сделано с ❤️ для Django сообщества
Metadata
Release files for admin-dj-helpers 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| admin_dj_helpers-0.1.0.tar.gz | 812.7 kB | With provenance | Details for admin_dj_helpers-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| admin_dj_helpers-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for admin_dj_helpers-0.1.0-py3-none-any.whl |
Total release size: 1.6 MB
Release files / admin_dj_helpers-0.1.0.tar.gz
| Download URL | admin_dj_helpers-0.1.0.tar.gz |
|---|---|
| Size | 812.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f5ab7e8aac29a49bcd7af8d57fc01eecba183cdf9798091874ec814d85c29ef
|
|
BLAKE2b-256 checksum How to use checksums |
978a2a80b60fef822883571b436276d4d6299ea28203696042f19ca40b6c3091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jul 16, 2025.
Transparency logRelease files / admin_dj_helpers-0.1.0-py3-none-any.whl
| Download URL | admin_dj_helpers-0.1.0-py3-none-any.whl |
|---|---|
| Size | 826.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24d03cbe4408875c191fdcf144f9158cb8f7aa9d355ca37fc50c81752aa28aa3
|
|
BLAKE2b-256 checksum How to use checksums |
75394e36c7e47eaac6d5a36fe0ac3dc32a48282de8ad178bb2e3a6800138ba9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jul 16, 2025.
Transparency logSecurity for admin-dj-helpers 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
Both files in this release have been uploaded with provenance metadata.
Attestation for admin_dj_helpers-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 Jul 16, 2025.
Transparency logA 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.