Get the latest tech news

Django: Fix a view using a debugger with breakpoint()


Python’s breakpoint() function opens its debugger, pdb, which pauses the program and allows you to inspect and modify things. Let’s look at an example of using it within a Django view, from a sample project included in Boost Your Django DX.

Python’s breakpoint() function opens its debugger, pdb, which pauses the program and allows you to inspect and modify things. Underneath the table are two filter buttons, “Hungry” and “Satiated”, which allow you to select only animals with those hunger levels. Compared to print() debugging, pdb allowed us to inspect the expressions we wanted without modifying the code, restarting the server, and reloading the page for each check.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of view

view

Photo of Django

Django

Photo of debugger

debugger

Related news:

News photo

COP29 Deal in View With an Outline for Climate Finance Blueprint

News photo

Philosopher of Change: How Henri Bergson's View of Reality Came to Be

News photo

The Practical Guide to Scaling Django