Skip to content

Commit

Permalink
feat: improvements, next release (#5)
Browse files Browse the repository at this point in the history
* feat: change dev project and README.md
* feat: add title to results.html
* docs: add screenshots

---------

Signed-off-by: Stanislav Filin <[email protected]>
  • Loading branch information
stasfilin authored Feb 10, 2024
1 parent 7c4f476 commit 152f0ee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Introduction
This Django application introduces a GlobalSearchView, designed to perform a global search across various models within the Django admin site.
![alt text](assets/main.png "Main Page")
![alt text](assets/results.png "Results Page")

## Features
* Global Search: Enables searching across multiple models from a single query.
Expand All @@ -19,7 +21,16 @@ 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.
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
</style>
{% endblock %}

{% block title %}Results for "{{ query }}" | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block content %}
<div class="admin-global-search-results">
<h1>{% trans "Search Results" %}</h1>
Expand Down
Binary file added assets/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dev/dev/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
# Application definition

INSTALLED_APPS = [
"admin_global_search",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"music",
"admin_global_search",
]

MIDDLEWARE = [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-admin-global-search"
version = "0.0.1"
version = "0.0.2"
description = "A global search for Django Admin UI"
authors = ["Stanislav Filin <[email protected]>"]
license = "BSD 3-Clause License"
Expand Down

0 comments on commit 152f0ee

Please sign in to comment.