I want to print the entire request object that comes to the server. I need to see all of the parameters that the request carries from the client since I don't have the clients's code (it's an Android client). I'm in the view.py file, and I'm using the function
我想打印到服务器的整个请求对象。我需要查看请求从客户端传递的所有参数,因为我没有客户端的代码(它是Android客户端)。我在view.py文件中,我正在使用该函数
def index(request):
return HttpResponse("test params")
to print the request object
打印请求对象
Please suggest code. It would be even better if I can print the request in the browser and not in the console.
请建议代码。如果我可以在浏览器中而不是在控制台中打印请求,那会更好。
2 个解决方案
#1
6
You can use Django Debug Toolbar which allows you to view a lot of debugging information including request and session.
您可以使用Django调试工具栏,它允许您查看许多调试信息,包括请求和会话。
From its documentation:
从其文件:
Currently, the following panels have been written and are working:
目前,以下小组已编写并正在运作:
- Django version
- Django版本
- Request timer
- 请求计时器
- A list of settings in settings.py
- settings.py中的设置列表
- Common HTTP headers
- 常见的HTTP标头
- GET/POST/cookie/session variable display
- GET / POST / cookie /会话变量显示
- Templates and context used, and their template paths
- 使用的模板和上下文及其模板路径
- SQL queries including time to execute and links to EXPLAIN each query
- SQL查询包括执行时间和每个查询的EXPLAIN链接
- List of signals, their args and receivers
- 信号列表,它们的参数和接收器
- Logging output via Python's built-in logging, or via the logbook module
- 通过Python的内置日志记录或通过日志模块记录输出
#2
4
from django.utils.html import escape
def index(request):
return HttpResponse(escape(repr(request)))
#1
6
You can use Django Debug Toolbar which allows you to view a lot of debugging information including request and session.
您可以使用Django调试工具栏,它允许您查看许多调试信息,包括请求和会话。
From its documentation:
从其文件:
Currently, the following panels have been written and are working:
目前,以下小组已编写并正在运作:
- Django version
- Django版本
- Request timer
- 请求计时器
- A list of settings in settings.py
- settings.py中的设置列表
- Common HTTP headers
- 常见的HTTP标头
- GET/POST/cookie/session variable display
- GET / POST / cookie /会话变量显示
- Templates and context used, and their template paths
- 使用的模板和上下文及其模板路径
- SQL queries including time to execute and links to EXPLAIN each query
- SQL查询包括执行时间和每个查询的EXPLAIN链接
- List of signals, their args and receivers
- 信号列表,它们的参数和接收器
- Logging output via Python's built-in logging, or via the logbook module
- 通过Python的内置日志记录或通过日志模块记录输出
#2
4
from django.utils.html import escape
def index(request):
return HttpResponse(escape(repr(request)))