Metadata-Version: 2.4
Name: django-admin-global-search
Version: 0.0.7
Summary: A global search for Django Admin UI
License: BSD 3-Clause License
License-File: LICENSE
Keywords: django,admin,global,search
Author: Stanislav Filin
Author-email: stas@filin.email
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: License :: OSI Approved :: BSD License
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: django (>=4.2.26,<5.0.0) ; python_version < "3.10"
Requires-Dist: django (>=5.1.14,<5.2.0) ; python_version >= "3.10"
Project-URL: Bug Tracker, https://github.com/stasfilin/django-admin-global-search/issues
Project-URL: Homepage, https://github.com/stasfilin/django-admin-global-search
Project-URL: Repository, https://github.com/stasfilin/django-admin-global-search
Description-Content-Type: text/markdown

# Django Admin Global Search
[![Downloads](https://static.pepy.tech/badge/django-admin-global-search)](https://pepy.tech/project/django-admin-global-search)
[![Downloads](https://static.pepy.tech/badge/django-admin-global-search/month)](https://pepy.tech/project/django-admin-global-search)
[![Downloads](https://static.pepy.tech/badge/django-admin-global-search/week)](https://pepy.tech/project/django-admin-global-search)

## Introduction
This Django application introduces a GlobalSearchView, designed to perform a global search across various models within the Django admin site.
![alt text](https://github.com/stasfilin/django-admin-global-search/blob/main/assets/main.png)
![alt text](https://github.com/stasfilin/django-admin-global-search/blob/main/assets/results.png)

## Features
* Global Search: Enables searching across multiple models from a single query.
* Dynamic Model Inclusion: Automatically includes models that define `global_search_fields`, allowing for flexible search configurations.
* Admin Integration: Provides direct links to the admin change page for each search result, facilitating easy editing.

## Getting Started:

### Prerequisites
* Python versions 3.8+.
* Django version 3+

### Installation Steps
Install with command `pip install django-admin-global-search`.

### Usage
To use `django-admin-global-search` in your Django project, you need to update your models and URL configurations.
1. Add `admin_global_search` to your `INSTALLED_APPS` setting before `django.contrib.admin`.
```python
INSTALLED_APPS = [
    "admin_global_search",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    ...
]
```
2. Ensure your models have a `global_search_fields` attribute that specifies the fields to be included in the search. Example:
```python
class Artist(models.Model):
    name = models.CharField(max_length=100)
    bio = models.TextField(blank=True)

    global_search_fields = ("name", "bio")

    def __str__(self):
        return self.name
```
2. Update your project's urls.py to include the GlobalSearchView. Example:
```python
...
from admin_global_search.views import GlobalSearchView


urlpatterns = [
    path("admin/", admin.site.urls),
    path("search/", GlobalSearchView.as_view(), name="admin_global_search"),
    ...
]
```

## Contributing
Contributions to the project are welcome. To contribute:
1. Fork the repository.
2. Create a new feature branch for your contribution.
3. Commit your changes with a descriptive message.
4. Push your changes to GitHub.
5. Submit a pull request for review.

## License
The project is made available under the **BSD 3-Clause License**. Please refer to the LICENSE file for more details.

