#27384: Accessing request.POST in Django middlewares 1.10.x make it empty for view -------------------------------------+------------------------------------- Reporter: Matheus Ashton | Owner: nobody Silva | Type: Bug | Status: closed Component: HTTP handling | Version: 1.10 Severity: Normal | Resolution: | worksforme Keywords: middleware | Triage Stage: request.POST | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Tim Graham):
* status: new => closed * needs_better_patch: => 0 * component: Uncategorized => HTTP handling * needs_tests: => 0 * needs_docs: => 0 * resolution: => worksforme Old description: > Hello, > > I'm creating a middleware to log every request in my API, following the > new specification on django 1.10.x. > > When I access the request.POST attr it goes blank to the view > > {{{ > #!div style="font-size: 80%" > Code highlighting: > {{{#!python > def log_request_middleware(get_response): > logger = logging.getLogger('requests') > > def middleware(request): > request_body = request.POST.copy().dict() > response = get_response(request) > }}} > }}} > > The request.POST on the view now is blank, it happens even with a simple > access a print or assignment. > > It also happens with request.GET New description: Hello, I'm creating a middleware to log every request in my API, following the new specification on django 1.10.x. When I access the `request.POST` attr it goes blank to the view. {{{#!python import logging def log_request_middleware(get_response): logger = logging.getLogger('requests') def middleware(request): request_body = request.POST.copy().dict() response = get_response(request) return response return middleware }}} The `request.POST` on the view now is blank, it happens even with a simple access a print or assignment. It also happens with `request.GET`. -- Comment: I cannot reproduce a problem with the middleware you provided (though it seems to have some missing lines which I added to the description). Can you provide a test case or a sample project to reproduce? -- Ticket URL: <https://code.djangoproject.com/ticket/27384#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.9da6cbdcb7c03e9071a7bb00ede27217%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.