Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从 django 错误页面访问控制台?
当我的模板产生错误时,我希望能够检查我的变量/查询集,而不必在import pdb; pdb.set_trace()每次我想从正在运行的应用程序进入控制台时返回并添加到我的视图中。
import pdb; pdb.set_trace()
pip3 install django-extensions # add 'django-extensions' to INSTALLED_APPS in settings.py pip3 install werkzeug python3 manage.py runserver_plus
现在,当您在浏览器中遇到错误时,您可以在将鼠标悬停在输出上时单击小控制台按钮。感谢@thebjorn 和@allcaps 为我指明了正确的方向
^>>>是您可以编写自己的命令的地方
>>>