Skip to content

Releases: ahmedaljawahiry/django-admin-site-search

1.1.0

16 Nov 16:13
Compare
Choose a tag to compare

Updates

  • Add overridable get_model_queryset method (#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 (#35).

1.0.0

03 Aug 16:45
Compare
Choose a tag to compare

New Features

New search method: ModelAdmin's search_fields (703dc84)

Set the site_search_method class attribute to admin_search_fields to delegate search to each ModelAdmin's get_search_results(). I.e. only search fields defined in an admin's search_fields (#22).

This also adds implicit support for searching through foreign keys (#20).

Credit to @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 (a85a556)

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 (6c1b68a)

  • .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 #26.