简体   繁体   中英

Django Basic HTTP AUTH

I am testing out Django 1.6 under Windows 7 using its integrated web server for debug purposes.

At some point I have a view that needs to be protected by authentication. (for debug purposes - not proper authentication).

The problem is that the browser won't ask me for authentication. This is my code:

if 'HTTP_AUTHORIZATION' in request.META:
    print 'the header is there!!'
    auth = request.META['HTTP_AUTHORIZATION'].split()
    ...

What should I do?

The browser won't ask for authentication unless you have the necessary header on the response

See answer here: https://stackoverflow.com/a/1087736/202168

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM