Giter VIP home page Giter VIP logo

django-term's Introduction

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

django-term's People

Contributors

synw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-term's Issues

module not found

Hello, file term/commands.py import err from goerr but it does not exist, how can I fix it

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.