Opened 8 years ago

Closed 8 years ago

#27384 closed Bug (worksforme)

Accessing request.POST in Django middlewares 1.10.x make it empty for view

Reported by: Matheus Ashton Silva Owned by: nobody
Component: HTTP handling Version: 1.10
Severity: Normal Keywords: middleware request.POST
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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.

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.

Change History (1)

comment:1 by Tim Graham, 8 years ago

Component: UncategorizedHTTP handling
Description: modified (diff)
Resolution: worksforme
Status: newclosed

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?

Note: See TracTickets for help on using tickets.
Back to Top