{"id":52,"date":"2014-06-30T22:05:46","date_gmt":"2014-06-30T14:05:46","guid":{"rendered":"http:\/\/vinta.ws\/code\/?p=52"},"modified":"2026-02-18T01:20:37","modified_gmt":"2026-02-17T17:20:37","slug":"debugging-django","status":"publish","type":"post","link":"https:\/\/vinta.ws\/code\/debugging-django.html","title":{"rendered":"Debug your Django project"},"content":{"rendered":"<p>How to debug in Django, the good way<br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/1118183\/how-to-debug-in-django-the-good-way\">http:\/\/stackoverflow.com\/questions\/1118183\/how-to-debug-in-django-the-good-way<\/a><\/p>\n<h2>pdb or ipdb<\/h2>\n<p>ref:<br \/>\nipdb: Interactive Python Debugger with IPython<br \/>\n<a href=\"https:\/\/vinta.ws\/code\/ipdb-interactive-python-debugger-with-ipython.html\">https:\/\/vinta.ws\/code\/ipdb-interactive-python-debugger-with-ipython.html<\/a><\/p>\n<h3>django-pdb<\/h3>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ pip install django-pdb\n$ .\/manage.py runserver 0.0.0.0:8000 --ipdb<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/tomchristie\/django-pdb\">https:\/\/github.com\/tomchristie\/django-pdb<\/a><\/p>\n<h3>Templatetags<\/h3>\n<pre class=\"line-numbers\"><code class=\"language-py\">from django import template\nregister = template.Library()\n\n@register.filter \ndef ipdb(element):\n    import ipdb; ipdb.set_trace()\n    return element<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/1118183\/how-to-debug-in-django-the-good-way\">http:\/\/stackoverflow.com\/questions\/1118183\/how-to-debug-in-django-the-good-way<\/a><\/p>\n<h2>django-extensions<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ pip install django-extensions\n$ .\/manage.py runserver_plus 0.0.0.0:8000<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/django-extensions\/django-extensions\">https:\/\/github.com\/django-extensions\/django-extensions<\/a><\/p>\n<h2>django-devserver<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ pip install django-devserver\n$ .\/manage.py runserver 0.0.0.0:8000 --werkzeug<\/code><\/pre>\n<p>\u4e0a\u9762\u9019\u5169\u500b plugins \u90fd\u662f\u7528 Werkzeug \u7684 interactive debugger<br \/>\n\u8ddf Flask \u7528\u7684\u90a3\u500b\u4e00\u6a23<br \/>\n\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728\u700f\u89bd\u5668\u7684 Traceback \u756b\u9762\u6309\u90a3\u500b terminal \u5716\u793a\u9032\u5165\u4e92\u52d5 debug \u6a21\u5f0f<\/p>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/dcramer\/django-devserver\">https:\/\/github.com\/dcramer\/django-devserver<\/a><\/p>\n<h2>django-debug-toolbar<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ pip install django-debug-toolbar<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/django-debug-toolbar\/django-debug-toolbar\">https:\/\/github.com\/django-debug-toolbar\/django-debug-toolbar<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to debug in Django, the good way<\/p>\n","protected":false},"author":1,"featured_media":278,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,116],"tags":[29,13,2],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-about-python","category-about-web-development","tag-debug","tag-django","tag-python"],"_links":{"self":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media\/278"}],"wp:attachment":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}