django: debugging code in the view layer
I am developing my first django website.
I have written code in my view layer (the handlers that return an HttpResponse object to the view template (hope I am using the correct terminology).
In any case, I want to put print statements in my views.py file, so that I can debug it. However, it looks like stdout has been redirect to another stream, so I am not seeing anything printed out on my console (or even the browser).
What is the recommended way (best practice) for debugging django view layer scripts?
Use the Python logging module. Then use the Django debug toolbar, which will catch and display all the things you send to the log.
there are more advanced ways of doing it, but i find dropping
import pdb pdb.set_trace()
does the job.