17👍
Put this in your view function:
from django.http import HttpResponse
return HttpResponse(str(var))
14👍
I just wanted to give an alternative answer: Simply use print
statements and serve your django site with python manage.py runserver
In this case the print
statements show up in your shell, and your site continues functioning as it would normally.
- [Django]-No handlers could be found for logger
- [Django]-Heroku, postgreSQL, django, comments, tastypie: No operator matches the given name and argument type(s). You might need to add explicit type casts
- [Django]-Django count RawQuerySet
3👍
If you are using mod_wsgi you can say:
print var
raise SystemExit
The SystemExit exception will not actually cause the whole process to exit as it would normally, but only cause that request to exit, presuming that no higher code catches it and ignores.
Ensure you are using mod_wsgi 3.X. If using older mod_wsgi, you would need to instead say:
import sys
print >> sys.stderr
raise SystemExit
Other WSGI servers may also treat SystemExit in a request the same way, say you would need to experiment as to what happens if using other hosting solution.
For other information about debugging WSGI applications read:
- [Django]-Factory-boy create a list of SubFactory for a Factory
- [Django]-Why won't Django use IPython?
- [Django]-Django Multiple Authentication Backend for one project
-1👍
If you don’t want to crash mod_wsgi on print’s do this in your wsgi file
sys.stdout = sys.stderr
prints will then be sent to the error_log
- [Django]-PyCharm: DJANGO_SETTINGS_MODULE is undefined
- [Django]-How do I run tests against a Django data migration?
- [Django]-Django REST Framework (DRF): Set current user id as field value