使用BPython作为Django应用程序的调试器

时间:2021-08-16 20:53:54

I'm currently developping a Django application and I like using the pdb to know in which state is my application and some stuff like that. I would like to have all the amazing capabilites of BPython inside the debuger... Like autocompletion and things like that.
Is that even possible ? Thanks :)

我目前正在开发一个Django应用程序,我喜欢使用pdb来了解我的应用程序和某些类似的东西。我想在debuger中拥有BPython所有令人惊叹的功能......就像自动完成和类似的事情一样。这有可能吗?谢谢 :)

1 个解决方案

#1


1  

Put some code in your python repl startup file to detect you're in a Django project, and perform the necessary imports:

在python repl启动文件中放入一些代码,以检测您是否在Django项目中,并执行必要的导入:

  1. put this in your ~/.bashrc or ~/.bash_profile
    export PYTHONSTARTUP=~/.pythonrc

    把它放在〜/ .bashrc或〜/ .bash_profile导出PYTHONSTARTUP =〜/ .pythonrc

  2. Create or edit your ~/.pythonrc:

    创建或编辑〜/ .pythonrc:

    try:
        from django.core.management import setup_environ
        import settings
        setup_environ(settings)
        print 'imported django settings'
    except:
        pass
    

    OR Use this more involved snippet that imports all your django modules and works in project subdirectories here: https://gist.github.com/pirate/2659b242bded82c3c58f2458e6885738#file-pythonrc-L56

    或者使用这个更复杂的代码片段导入所有django模块并在这里的项目子目录中工作:https://gist.github.com/pirate/2659b242bded82c3c58f2458e6885738#file-pythonrc-L56

#1


1  

Put some code in your python repl startup file to detect you're in a Django project, and perform the necessary imports:

在python repl启动文件中放入一些代码,以检测您是否在Django项目中,并执行必要的导入:

  1. put this in your ~/.bashrc or ~/.bash_profile
    export PYTHONSTARTUP=~/.pythonrc

    把它放在〜/ .bashrc或〜/ .bash_profile导出PYTHONSTARTUP =〜/ .pythonrc

  2. Create or edit your ~/.pythonrc:

    创建或编辑〜/ .pythonrc:

    try:
        from django.core.management import setup_environ
        import settings
        setup_environ(settings)
        print 'imported django settings'
    except:
        pass
    

    OR Use this more involved snippet that imports all your django modules and works in project subdirectories here: https://gist.github.com/pirate/2659b242bded82c3c58f2458e6885738#file-pythonrc-L56

    或者使用这个更复杂的代码片段导入所有django模块并在这里的项目子目录中工作:https://gist.github.com/pirate/2659b242bded82c3c58f2458e6885738#file-pythonrc-L56