Categorized: Django, JavaScript
How to Log Something
With The Django Debug Toolbar
Somewhere in your Python code (not a template):
import logging
logging.debug(something_you_want_to_log)
With Firebug
Somewhere in your JavaScript or the Firebug Console:
console.log(something_you_want_to_log);
That was easy.
Comments
Don’t forget to check if the console.log object is available before using it or your code will break if firebug isn’t running. I usually add this at the top of my javascript code:
There are also fancier solutions for this problem.
Or you can use firebug LITE that is a javascript rewrite of firebug, so console.log will work in every browser.
http://getfirebug.com/lite.html
What do you think about that?