Created
January 30, 2013 01:27
-
-
Save drewtempelmeyer/4669799 to your computer and use it in GitHub Desktop.
Django SSL Mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.http import HttpResponseRedirect | |
class SSLRequiredMixin(object): | |
def dispatch(self, request, *args, **kwargs): | |
if settings.DEBUG is False and request.is_secure() is False: | |
host = request.get_host() | |
url = 'https://%s%s' % (host, request.get_full_path()) | |
return HttpResponseRedirect(url) | |
return super(SSLRequiredMixin, self).dispatch(request, *args,**kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment