Django request.is_ajax returning false

前端 未结 6 1959
清歌不尽
清歌不尽 2020-12-09 09:12

I am testing out ajax with Django + jQuery. I have this in my views:

def ajax_test(request):
    if request.is_ajax():
        message = \"This is ajax\"
            


        
6条回答
  •  情书的邮戳
    2020-12-09 09:58

    Probably you've got APPEND_SLASH turned on (the default), and Django is redirecting from /ajax_test to /ajax_test/ but not preserving the relevant header. Better to request the version with the slash in the first place.

提交回复
热议问题