send request body using a decorator in python
<p>I have a function in a django project something like this:</p>

<pre><code>class my_class():

def post(self, request, id, format=None):
    logger.info(
                ''.join(
                    ["id"+str(request.get('id')),
                     "name"+str(request.get('name')),
                     "grade"+str(request.get('grade'))]
               )
     )
    row = Student(
         id = request.get('id'),
         name = request.get('name'),
         grade = request.get('grade')
    )
    row.save()
</code></pre>

<p>Now I want to have a decorator(<strong>@logger</strong>) around my this function which logs everything inside (logger.info). i.e I should only add @logger above the function definition and can log all the request body. Can someone help me how can I do this. I am facing problem in sending the request body from <code>post</code> to the decorator.</p>

<pre><code>def logger(func):
    def decorator(request, *args, **kwargs):
        # log here
        return func(request, *args, **kwargs)
    return decorator
</code></pre>

python django request decorator