Django-admin-site-search

Latest version: v1.1.0

Safety actively analyzes 681812 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

1.1.0

Updates

- Add overridable `get_model_queryset` method (https://github.com/ahmedaljawahiry/django-admin-site-search/issues/33):

def get_model_queryset(self, request, model_class: Model, model_admin: Optional[ModelAdmin]) -> QuerySet:
"""DEFAULT: Returns the model class' .objects.all() queryset."""


- Add/test Django 5.1 support (https://github.com/ahmedaljawahiry/django-admin-site-search/issues/35).

1.0.0

New Features

New search method: ModelAdmin's search_fields (https://github.com/ahmedaljawahiry/django-admin-site-search/commit/703dc8414545773e015fcb3c5ade78836b4178d5)

Set the `site_search_method` class attribute to `admin_search_fields` to delegate search to each ModelAdmin's [get_search_results()](https://docs.djangoproject.com/en/5.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_search_results). I.e. only search fields defined in an admin's [search_fields](https://docs.djangoproject.com/en/5.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields) (https://github.com/ahmedaljawahiry/django-admin-site-search/issues/22).

This also adds implicit support for searching through foreign keys (https://github.com/ahmedaljawahiry/django-admin-site-search/issues/20).

Credit to [kevinrenskers](https://github.com/kevinrenskers) for the idea.

Note - by default `site_search_method` is set to `model_char_fields`, which is the original behaviour. This default may be flipped in a future release.

Breaking changes

1. `request` is now the first argument passed to all methods (https://github.com/ahmedaljawahiry/django-admin-site-search/commit/a85a556d5446402f5a0ef6800474eba4a8025824)

For methods - that may be overridden - such as `match_objects` or `match_model`, the first argument is now Django's `request` object.

2. Button CSS updates (https://github.com/ahmedaljawahiry/django-admin-site-search/commit/6c1b68a05f7846bf33e2af68d24074008d6f53e1)

- `.search-button`'s `background-color` now uses `--primary`.
- `.search-button:hover` now applies `--header-branding-color` to the `svg` (search icon).

Visually, the difference is minimal. This is a simple fix for https://github.com/ahmedaljawahiry/django-admin-site-search/issues/26.

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.