A Django Admin Shell
Project description
Django Admin Shell
A Django Web Shell using Xterm.js and Django Channels.
Note: This package depends on websockets therefore you'll need to use an ASGI application to use it. If you are not using Django channels then read through the official Channels' documentation on installing Channels, also see the Channels' documentation on running ASGI applications.
Demo
The demo is from Django.wtf's admin.
Features
- Fully responsive terminal using Xterm.js.
- Accessible through the admin.
- Authentication with Django auth, configurable to allow only superusers.
- The commands written are tied to a user.
- Saves command in a new model and create favorite commands.
- Filterable command history.
- LogEntry of all commands ran.
- Custom admin site to add Terminal links to the admin.
- Full screen mode.
- Working autocomplete.
Installation
Install the package using pip:
pip install django-admin-shellx
Add django_admin_shellx
to your INSTALLED_APPS
:
INSTALLED_APPS = [
# ...
'django_admin_shellx',
# ...
]
Since the package uses websockets you'll need to add the url patterns to your ASGI application:
...
from django_admin_shellx.urls import websocket_urlpatterns
application = ProtocolTypeRouter(
{
"http": django_asgi_app,
"websocket": AllowedHostsOriginValidator(
AuthMiddlewareStack(URLRouter(websocket_urlpatterns))
),
}
)
Lastly, we'll need to use a custom admin site to add a link to the terminal, add the following to your INSTALLED_APPS
:
INSTALLED_APPS = [
...
"django_admin_shellx",
"django_admin_shellx_custom_admin.apps.CustomAdminConfig",
]
Ensure to remove the default admin
app from the INSTALLED_APPS
if you are using the custom admin site.
INSTALLED_APPS = [
...
# 'django.contrib.admin',
...
]
The above is optional and only adds a view
button to the admin that links to the terminal. Otherwise, there will not be a link since it's not a model and can not be added to the admin. The terminal will either be accessible through the path /admin/django_admin_shellx/terminalcommand/terminal/
and if you use the custom admin site, it will be accessible through a link in the admin.
Usage
Head over to the admin and click on the Terminal
link. You'll be presented with a terminal that you can use to run commands. The default commands are ./manage.py shell_plus
, ./manage.py shell
and /bin/bash
. You can change the default commands by setting the DJANGO_ADMIN_SHELLX_COMMAND
setting.
Each command is saved in the database and can be accessed through the admin. You can also add new commands through the admin and favorite existing commands. Each command ran is also saved as a LogEntry.
Settings
Name | Description | Type | Default | Required |
---|---|---|---|---|
DJANGO_ADMIN_SHELLX_SUPERUSER_ONLY | Only allow superusers to access the admin shellx. | boolean |
True |
no |
DJANGO_ADMIN_SHELLX_COMMANDS | The default commands to use when opening the terminal. | list[list[str]] |
[["./manage.py", "shell_plus"], ["./manage.py", "shell"], ["/bin/bash"]] | no |
DJANGO_ADMIN_SHELLX_WS_PORT | The port to use for the websocket. | int |
None | no |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_admin_shellx-0.2.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 792354701be0a7f8b43ffa49acb57dca7d321655bc101ff8321b60664bebd88a |
|
MD5 | 63a67cc0a543bf73ca3815eb77e67fea |
|
BLAKE2b-256 | 1ceaddaadd279729415213a9cb17b0aed17610deaf485cd42a20ea826694ba49 |
Hashes for django_admin_shellx-0.2.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ede28980bb3a5e46373ba131df53b4c16e95889d875099dc003ddada14b7ee58 |
|
MD5 | eb505e8e9c7d82cfdf66ce0047230eb3 |
|
BLAKE2b-256 | 090acc92fcce92d33dff6125a1dd3370baa714e8c39b8f6b0f62a13810fbbfbe |