How to access custom HTTP request headers on Django Rest Framework?

The name of the meta data attribute of request is in upper case:

print request.META

If your header is called “My-Header”, your header will be available as:

request.META['HTTP_MY_HEADER']

Or:

request.META.get('HTTP_MY_HEADER') # return `None` if no such header

Quote from the documentation:

HTTP headers in the request are converted to META keys by converting all characters to uppercase, replacing any hyphens with underscores and adding an HTTP_ prefix to the name. So, for example, a header called X-Bender would be mapped to the META key HTTP_X_BENDER.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)