In Django can I dump out a variable to see what is in it within a view (not using command line)?
for example:
device = mobile(request)
print device
abort
or
device = mobile(request)
return HttpResponse(device)
Writing to a file is usually a fool-proof way to "dump" data as a debug method when you are working with a hooked framework that doesn't otherwise lend itself well to direct debugging.
e.g.
device = mobile(request)
with open('path/to/debug_out.txt', 'w') as outfile:
outfile.write(device)
abort
for convenience, you could put this in a predefined function in some debug helper module. Alternatively, you could use sys.excepthook to automatically write all exceptions to this file, before forwarding/re-raising them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With