Quick Start
Project Status
Development
This project is in development and may introduce breaking changes in future releases.
Basic Setup
1. Install the Package
2. Add to INSTALLED_APPS
# settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django_global_search', # Add this line
# ... other apps
]
3. Access Global Search
Start your development server:
Navigate to: http://localhost:8000/admin/global-search/
Adding a Navigation Button (Optional)
Instead of typing the URL directly, you can add a search button to the Django Admin interface.
Create templates/admin/base_site.html in your project:
{% extends "admin/base_site.html" %}
{% block userlinks %}
{{ block.super }}
{% include 'global_search/button.html' %}
{% endblock %}
This adds a "Global Search" button next to the user links in the admin header.
Template Location
Make sure your templates/ directory is configured in TEMPLATES settings:
How It Works
Automatic Model Detection
Django Global Search automatically includes all models that:
- Are registered in Django Admin
- Have
search_fieldsdefined in their ModelAdmin - The current user has view permission for
Example ModelAdmin
# admin.py
from django.contrib import admin
from .models import Article, Author
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
search_fields = ['title', 'content', 'author__name']
list_display = ['title', 'author', 'published_date']
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
search_fields = ['name', 'email', 'bio']
list_display = ['name', 'email']
With the above configuration, global search will automatically search across both Article and Author models using their respective search_fields.
Using the Search Interface
Search Across All Models
- Visit
/admin/global-search/ - Enter your search query (minimum 2 characters by default)
- Press Enter or click Search
- Results are grouped by app and model
Filter by Specific Models
Use the sidebar to select specific models to search:
- Check/uncheck models you want to include
- Results will only show from selected models
- Selections persist during your session
View Full Results
Click "View all results" link under any model to see the full changelist with your search query applied.
Understanding Results
Results are organized hierarchically:
Permissions
Global search respects Django's permission system:
- Users only see models they have
viewpermission for - Object-level permissions are checked before displaying results
- Models without
has_module_permissionare excluded
Next Steps
- Configuration - Customize search behavior, timeouts, and result limits
- Learn about custom AdminSite integration (coming soon)