This project has moved. For the latest updates, please go here.

POST Data + Debugging Django Unittests

Aug 19, 2014 at 3:35 PM

I have the following unit test:
    def test_post(self):
        response ='/', { 'data': 'somedata' })
The view does nothing but raising an exception:
    raise Exception(request.POST)
When calling the unit test via "Run", the POST data is correctly shown in the output.

When debugging the unit test via "Debug", request.POST is empty. How can this be avoided?
Aug 20, 2014 at 8:54 AM
Edited Sep 3, 2014 at 7:27 AM
When setting a breakpoint, after request.POST is accessed, it works:
    def home(request):
        post = request.POST // When a breakpoint is set here, request.POST is NOT set
        raise Exception(post) // When a breakpoint is only set here, post and request.POST is set
So I will use this as a temporary workaround.

The same does not only apply to unit tests but also to normal debugging. The same goes for other objects like django cursor - added a workitem (
Marked as answer by Dresel on 9/3/2014 at 12:27 AM