Created
June 24, 2013 18:26
-
-
Save HugoPresents/5852265 to your computer and use it in GitHub Desktop.
Django determine the request method is ajax?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_ajax(request): | |
try: | |
if request.META['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest': | |
return True | |
else: | |
return False | |
except KeyError: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment