django debug toolbar Logging at POST Request

683 views Asked by At

I am new to web develpment so forgive me if that question may be obvious or stupid.

I managed to get the django debug toobar running and it shows the logs all right on a GET request.

When I do a POST request the django debug toolbar does not show the logs that were triggered by the POST request. It does not update. for local development a print to console works, for server side obviously not. On server side I would have to write to a file which is suboptimal.

Maybe that is how it is supposed to be, but then the debug toolbar would be of little use for me.

Is the debug toolbar supposed to update in response to POST requests?

Thank you Alain


EDIT:

the chromelogger extension does in principle what I need.

here is my view function:

from lib_share import json_own  
import sys  
from django.shortcuts import render  
from django.http import HttpResponse  
import chromelogger as console  
import logging  
logger = logging.getLogger(__name__)

def tree_test7(request):  
    logger.debug('I log a GET')  
    if request.method == 'POST':  
        logger.debug('I log a POST')  
        console.log('chromelogger I log a POST')  
        response = HttpResponse("Hello my friend")  
        return response  
return render(request, "tree_test7.html")  

the log of the GET request gets logged in the toolbar, but the many POST request you see in the screenshot on:

https://i.stack.imgur.com/5jrZy.png

do not get logged in the debug-toolbar. there is still just one entry.

The chromelogger extension gets the job done though, as you can seen in the screenshot. Any click on the drop down list triggers a POST request, which gets logged to chrome console in case of the chromelogger.

many thanks Alain

0

There are 0 answers