Printing an HTTP Request in Python Django

I want to print the entire request object that comes to the server. I need to see all the parameters that the request carries from the client, since I do not have a client code (this is an Android client). I am in the view.py file and I use the function

def index(request): return HttpResponse("test params") 

to print the request object

Please suggest a code. It would be even better if I could print the request in the browser, and not in the console.

+8
python django
source share
2 answers

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

From the documentation:

The following panels are currently written and work:

  • version of django
  • Request Timer
  • List of settings in settings.py
  • Common HTTP Headers
  • Displaying GET / POST / cookie / session variables
  • Used patterns and contexts and their paths to patterns
  • SQL queries, including runtime, and links to EXPLAIN each query
  • List of signals, their arguments and receivers
  • Log output through the built-in Python log or through the log module
+6
source
 from django.utils.html import escape def index(request): return HttpResponse(escape(repr(request))) 
+4
source

All Articles