Shell tab completion for Django management commands. This package generates the autocomplete options for your project to be loaded by your profile.
- Automatic discovery of all Django management commands in your project
- Generates file to be loaded by your profile for the generated project directory
- Make this readme more fancy
- Identify each project by checking the folder name or virtual environment and use specific commands
- Tab completion for command names and their arguments
- Support for argument choices when available
- Supports:
- PowerShell
- Bash (untested)
- Review and remove unnecessary requirements
pip install django-command-autocomplete- Add 'django_command_autocomplete' to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
'django_command_autocomplete',
]- Generate the completion script for your shell:
For PowerShell:
python manage.py generate_shell_completion powershellFor Bash:
python manage.py generate_shell_completion bashYou can also specify a custom output path:
python manage.py generate_shell_completion powershell --output ~/.config/django-completion.ps1
python manage.py generate_shell_completion bash --output ~/.config/django-completion.sh- Set up automatic loading:
a. First, check if you have a PowerShell profile:
Test-Path $PROFILEb. If it returns False, create the profile:
New-Item -Path $PROFILE -Type File -Forcec. Add the following line to your PowerShell profile:
. $PSScriptRoot\django_completion.ps1d. Reload your profile:
. $PROFILEa. Add the following line to your ~/.bashrc (or ~/.bash_profile on macOS):
source ~/path/to/django_completion.shb. Reload your bashrc:
source ~/.bashrcAlternatively, you can manually source the script in each shell session:
PowerShell:
. .\django_completion.ps1Bash:
source ./django_completion.shNow you can use the dj command (alias for python manage.py) with tab completion:
dj [TAB] # Shows all available commands
dj runserver --[TAB] # Shows all available arguments for runserverThe package discovers all available Django management commands in your project and their arguments. It generates a shell script that provides tab completion through your shell's native completion mechanism.
The generated script:
- Creates an alias
djforpython manage.py - Registers a tab completion handler for the
djcommand - Provides completion for:
- Command names
- Command arguments
- Argument choices (when available)
Contributions are welcome! Please feel free to submit a Pull Request.
- Install uv
- Download source
- Run
uv sync --all-groupsto include the dev and test requirements - Run
uv run pre-commit installto install the pre-commit hooks - Run 'uv venv venv' to create the virtual environment
This project is licensed under the MIT License - see the LICENSE file for details.