Site icon Satish Gandham

Right way to break Django code for debugguing

Django traceback is a very helpful tool in Django development. It saves us from the boring tasking of writing print statements to track variables.

Traceback doesn’t kick when there is no error.  There may be no coding errors but there is a flaw in our application logic which we want to debug. In such cases we can trigger Django traceback by adding assert False in our code.

example:

def hello_world(response):
test_var = "Something"
test_var2 = "another var"
assert false
return HttpResponse(test_var+test_var2)

Exit mobile version