Print HTTP request in Python Django

You can use Django Debug Toolbar which allows you to view a lot of debugging information including request and session.

From its documentation:

Currently, the following panels have been written and are working:

  • Django version
  • Request timer
  • A list of settings in settings.py
  • Common HTTP headers
  • GET/POST/cookie/session variable display
  • Templates and context used, and their template paths
  • SQL queries including time to execute and links to EXPLAIN each query
  • List of signals, their args and receivers
  • Logging output via Python's built-in logging, or via the logbook module

from django.utils.html import escape
def index(request):
    return HttpResponse(escape(repr(request)))

Tags:

Python

Django