CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 09:01:44 GMT
content-type: text/html; charset=utf-8
cross-origin-opener-policy: same-origin
nel: {"report_to":"heroku-nel","response_headers":["Via"],"max_age":3600,"success_fraction":0.01,"failure_fraction":0.1}
referrer-policy: same-origin
report-to: {"group":"heroku-nel","endpoints":[{"url":"https://nel.heroku.com/reports?s=llxaKd%2BTbfA9wGPcbiBFt1oJMsH2HsJO9OYUqyKrufA%3D\u0026sid=af571f24-03ee-46d1-9f90-ab9030c2c74c\u0026ts=1760173304"}],"max_age":3600}
reporting-endpoints: heroku-nel="https://nel.heroku.com/reports?s=llxaKd%2BTbfA9wGPcbiBFt1oJMsH2HsJO9OYUqyKrufA%3D&sid=af571f24-03ee-46d1-9f90-ab9030c2c74c&ts=1760173304"
server: cloudflare
strict-transport-security: max-age=15552000; includeSubDomains; preload
vary: Cookie
via: 1.1 heroku-router
x-content-type-options: nosniff
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: csrftoken=qleJpzYj70QbfxtTCUqOWRC2Gq5VSglj; SameSite=Lax; Path=/; Max-Age=31449600; Expires=Sat, 10 Oct 2026 09:01:44 GMT
cf-ray: 98cd2ca9ff6c3ed9-BOM
alt-svc: h3=":443"; ma=86400
djangosnippets: JSONRequestMiddleware adds a .json() method to your HttpRequests
JSONRequestMiddleware adds a .json() method to your HttpRequests
add JSONRequestMiddleware to your enabled middleware in Django settings. Now, in your view functions, you can call request.json() to get a parsed json body! json is consumed lazily, and cached.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import json from functools import lru_cache, partial from django.http import HttpRequest def _lazy_json(request): return json.loads(request.body) def JSONRequestMiddleware(get_response): def middleware(request: HttpRequest): request.json = lru_cache(partial(_lazy_json, request)) response = get_response(request) return response return middleware |
More like this
- Add Toggle Switch Widget to Django Forms by OgliariNatan 1 month ago
- get_object_or_none by azwdevops 4 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 6 months, 3 weeks ago
- Template tag - list punctuation for a list of items by shapiromatron 1 year, 8 months ago
- Serializer factory with Django Rest Framework by julio 2 years, 3 months ago
Comments
Please login first before commenting.