2014-10-18 28 views
3

我正在學習DjangoDjangoshellshell是一個常用的東西,但它有點令人沮喪的來回切換到終端窗口。使用SublimeREPL作爲Django shell

我嘗試使用SublimeREPL-shell,但它無法正常工作。例如,我可以用python manage.py shell進入在REPL窗口中的交互式控制檯,而在此之後將不顯示所有命令和結果:它看起來像這樣

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) 

好了,結果將顯示,如果我他們都會出現(但有點太遲了......)。像這樣的東西

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

所以我不知道這是否正確地做到這一點?

回答

4

manage.py路徑中的新.py文件。它包含這些。

#!/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']) 

使用方法:菜單>工具> SublimeREPL>的Python> Python的 - 運行當前文件