Serving secure Django pages with HTTPS

2019-02-07 00:14发布

What is the proper deployment configuration for a Django application that needs some pages served with HTTPS and others with HTTP? I want to use HTTPS for the pages that involve registration and inputting passwords. I want to use HTTP for all other pages.

1条回答
Fickle 薄情
2楼-- · 2019-02-07 00:37

There's no single approach as far as I know. You can use a decorator secure_required as developed in this post by Scott Barnham:

or use middleware:

If you're looking for deployment information with respect to Apache and mod_wsgi, then Graham Dumpleton provides a nice answer in this question:

查看更多
登录 后发表回答