Skip to main content
Commonmark migration
Source Link

In most cases you can set Apache or something to redirect to https, as described in the accepted answer. And if you can, that would be better, for performance and for files served outside Django.

But if you cannot, or want to do debugging, then I would like to point out that Django recently (1.8) introduced a SecurityMiddleware which has https-redirects as one of it's several functions.

More info is available in [the documentation][1]the documentation. Basically, add django.middleware.security.SecurityMiddleware and set SECURE_SSL_REDIRECT = True.

(The header mentioned by the accepted answer can also be set by this middleware.) [1]: https://docs.djangoproject.com/en/1.8/ref/middleware/#module-django.middleware.security

In most cases you can set Apache or something to redirect to https, as described in the accepted answer. And if you can, that would be better, for performance and for files served outside Django.

But if you cannot, or want to do debugging, then I would like to point out that Django recently (1.8) introduced a SecurityMiddleware which has https-redirects as one of it's several functions.

More info is available in [the documentation][1]. Basically, add django.middleware.security.SecurityMiddleware and set SECURE_SSL_REDIRECT = True.

(The header mentioned by the accepted answer can also be set by this middleware.) [1]: https://docs.djangoproject.com/en/1.8/ref/middleware/#module-django.middleware.security

In most cases you can set Apache or something to redirect to https, as described in the accepted answer. And if you can, that would be better, for performance and for files served outside Django.

But if you cannot, or want to do debugging, then I would like to point out that Django recently (1.8) introduced a SecurityMiddleware which has https-redirects as one of it's several functions.

More info is available in the documentation. Basically, add django.middleware.security.SecurityMiddleware and set SECURE_SSL_REDIRECT = True.

(The header mentioned by the accepted answer can also be set by this middleware.)

Source Link
Mark
  • 333
  • 2
  • 8

In most cases you can set Apache or something to redirect to https, as described in the accepted answer. And if you can, that would be better, for performance and for files served outside Django.

But if you cannot, or want to do debugging, then I would like to point out that Django recently (1.8) introduced a SecurityMiddleware which has https-redirects as one of it's several functions.

More info is available in [the documentation][1]. Basically, add django.middleware.security.SecurityMiddleware and set SECURE_SSL_REDIRECT = True.

(The header mentioned by the accepted answer can also be set by this middleware.) [1]: https://docs.djangoproject.com/en/1.8/ref/middleware/#module-django.middleware.security