Skip to main content
2 of 2
Commonmark migration

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.)

Mark
  • 333
  • 2
  • 8