Django Rest Framework debug post and put requests

前端 未结 4 1648
迷失自我
迷失自我 2021-02-19 12:02

I use DRF extension to se json list for model, and there i can debug with debug-toolbar that GET request, but how can i debug POST and

4条回答
  •  执笔经年
    2021-02-19 12:46

    You can not intercept redirects in DRF browsable api because it is ajax and called via javascript. Also the toolbar is not shown because of ajax call. As workaround you could temporary comment lines in debug_toolbar.middleware.DebugToolbarMiddleware#process_request that disables toolbar in ajax call:

        ...
        # Don't render the toolbar during AJAX requests.
        # if request.is_ajax():
        #     return
        ...
    

    Redirects still would not work, but toolbar would be visible.

提交回复
热议问题