synw/django-term


In browser terminal for Django

License: MIT

Language: JavaScript

Keywords: django-instant


Django Term

In browser terminal for Django that enables custom commands

Install

Dependency: Django Instant for the websockets: install doc

pip install django-term

Add "term", to installed apps:

Set the urls

from instant.views import instant_auth

urlpatterns = [
   url('^terminal/', include('term.urls')),
   url('^instant/', include('instant.urls')),
   url('^centrifuge/auth/$', instant_auth, name='instant-auth'),
]

Add to settings.py:

SITE_SLUG = "mysite"
INSTANT_SUPERUSER_CHANNELS = [
 ["$" + SITE_SLUG + "_terminal", ["/terminal"]]
]

Create a templates/instant/handlers/$mysite_terminal.js whith this content:

{% include "term/handlers.js" %}

Run the websockets server and go to /terminal/

Commands

Note: to use the commands from third-party apps your must have these apps installed

help: display info about the available commands

ping: ping the server

clear: clears the screen

From Django Introspection:

inspect: gives infos about an app or model. Params: appname or appname.Modelname: ex: inspect auth.User

From Django Dex:

replicatedb: replicates the 'default' db into a sqlite 'replica' db

Create a command

Create a terminal folder in any app. Create a commands.py file inside this directory:

from term.commands import Command, rprint

def run_hello(request, cmd_args):
   rprint("Hello world")
 
# Args are the command name, the runner function and the help text
c1 = Command("hello", run_hello, "Hello world command")
COMMANDS = [c1]

Your command will be detected at startup and enabled in the terminal

To debug a command during developement use TERM_DEBUG_MODEL = "mymodel"

Apps that have terminal commands:

django-introspection: get infos about Django objects

django-dex: database export tools

django-jobrunner: experimental asynchronous jobs runner

Customize the ui

To customize the colors use the terminal/colors.css template

Screenshot

Terminal

Project Statistics

Sourcerank 4
Repository Size 178 KB
Stars 1
Forks 0
Watchers 2
Open issues 0
Dependencies 4
Contributors 1
Tags 4
Created
Last updated
Last pushed

Top Contributors See all

synw

Packages Referencing this Repo

django-term
In browser term for Django
Latest release 0.2.1 - Updated - 1 stars

Recent Tags See all

0.2.1 January 13, 2018
0.2 January 12, 2018
0.1.4 December 10, 2017
0.1 December 10, 2017

Something wrong with this page? Make a suggestion

Last synced: 2018-03-26 16:23:53 UTC

Login to resync this repository