Django Debugging Using "assert False"

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

While developing, inserting the following line to your code:

assert False, value

will cause django to raise an AssertionError with the value supplied as an error message when this line is executed.

If this occurs in a view, or in any code called from a view, and DEBUG=True is set, a full and detailed stacktrace with a lot of debugging information will be displayed in the browser.

Don't forget to remove the line when you are done!



Got any Django Question?