GitHub - anze3db/django-tui: Inspect and run Django Commands in a text-based user interface (TUI) · GitHub
Skip to content

About

Inspect and run Django Commands in a text-based user interface (TUI)

Topics

Resources

Stars

298 stars

Watchers

4 watching

Forks

Repository files navigation

django-tui

Inspect and run Django Commands in a text-based user interface (TUI), built with Textual.

PyPI - Version PyPI - Python Version

A demo of django-tui: filtering commands, filling in a command's options and running it, then querying models in the shell

Commands

Type a command and its arguments, like in your shell, or fill in the form. Your project's commands are listed first.

The command screen with the closepoll command and its options

Shell

Run ORM queries with your models and common Django helpers already imported.

The shell with a query and its result

Try it without installing

Run django-tui with uv in your project's directory, or any directory inside it:

uvx django-tui

It finds your project's manage.py, loads the .env files in the project's directory and its parents (variables that are already set win), and uses the project's virtual environment: the active one, or a .venv, venv or env directory in the project or its parents. Arguments work like they do for python manage.py tui, e.g. uvx django-tui --shell or uvx django-tui --settings=mysite.settings.local.

If your virtual environment is somewhere else, like with Poetry, activate it first, e.g. poetry run uvx django-tui.

Installation

pip install django-tui

Add "django_tui" to your INSTALLED_APPS setting in settings.py like this:

INSTALLED_APPS = [
    ...,
    "django_tui",
]

Now you can run the TUI with:

python manage.py tui

Type a command at the $ python manage.py prompt at the top, just like in your shell, e.g. migrate myapp --plan. The command name filters the list of commands and the arguments fill in the form below it. Changing the form updates the command too.

Press enter to run the command. It runs inside the TUI's process, so Django doesn't have to start up again for each one. When the command finishes, press enter to go back to the TUI.

Key Action
enter Run the command
↑ ↓ Pick a command from the list
→ Accept the suggested command name
tab Complete the command name and edit its options
ctrl+r Run the command (while editing options)
ctrl+y Copy the command to the clipboard
esc Back to the command line, or clear it
ctrl+j Switch between commands and the shell
ctrl+c Copy the selected text, or press twice to quit

Open the interactive shell directly with python manage.py tui --shell. Press ctrl+r to run your code; the value of the last expression is shown in the output.

Contributing

You need uv and just. just lists the tasks: just check lints and runs the tests, just test-all runs them on every supported Python and Django, and just tui opens the TUI in the test project. just screenshots and just demo save the images above for the next version, in docs/images/<version>/, and point this README at them. Keep the old images: PyPI shows each release's README with that release's images. Releases are described in RELEASING.md.

License

django-tui is distributed under the terms of the MIT license.

Looking for Django Admin in your termain?

Checkout @valberg's django-admin-tui project!

About

Inspect and run Django Commands in a text-based user interface (TUI)

Topics

Resources

Stars

298 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages