Django custom handler404 shows 404 but gives header 200

后端 未结 6 936
春和景丽
春和景丽 2020-12-15 11:58

I made a custom handler404 for a authenticated Django website to avoid information leakage.

def check_logged_in_404(request):
    \"\"\" Custom 404. Show fr         


        
6条回答
  •  忘掉有多难
    2020-12-15 12:12

    I finally found why the returned status code didnt work. Instead of setting a header message, it simply is:

    response.status_code = 404
    

    Nevertheless, the code suggested by PiotrLegnica definitely wins on simplicity, readability and beauty .. The badge still stands ;)

    Regards,

    Gerard.

提交回复
热议问题