[Fixed]-Print HTTP request in Python Django

6๐Ÿ‘

โœ…

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
๐Ÿ‘คalmalki

8๐Ÿ‘

import sys

def req(request)
   print(request.__dict__, file=sys.stderr)

7๐Ÿ‘

from django.utils.html import escape
def index(request):
    return HttpResponse(escape(repr(request)))
๐Ÿ‘คmderk

Leave a comment