3

I am learning Django, and Django shell is a frequently used thing, but it is a bit frustrating to switch back and forth to the Terminal window.

I try to use SublimeREPL-shell, but it does not work properly. For instance, I can use python manage.py shell to enter the interactive console in the REPL window, but after that all command and results will not be displayed: it look something like this

bash: no job control in this shell
bash-3.2$ python manage.py shell
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

Well, the results will be displayed if I quit() and they will all show up (but a bit too late...). Something like this

Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> >>> [<Person: John>, <Person: Jane>]
>>> bash-3.2$ 

So I wonder if this is a way to do it properly?

Lelouch
  • 2,111
  • 2
  • 23
  • 33

1 Answers1

4

New a .py file in the path of manage.py. it contain these.

#!/usr/bin/env python
# run Django shell in SublimeREPL
# how to use: Meuns > Tools > SublimeREPL > Python > Python - RUN current file
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "[your app].settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(['.', 'shell'])

How to use: Menus > Tools > SublimeREPL > Python > Python - RUN current file

ponder
  • 71
  • 7