1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """
In your site's __init__.py
"""
from django.core import urlresolvers
from django.conf import settings
def reverse_decorator(func):
def inner(*args, **kwargs):
abs_path = func(*args,**kwargs)
if settings.SSL_DOMAIN and settings.SSL_SECTIONS and settings.SSL_DOMAIN.startswith('https'):
for section in settings.SSL_SECTIONS:
if abs_path.startswith(section):
abs_path = settings.SSL_DOMAIN + abs_path
break
return abs_path
return inner
urlresolvers.reverse = reverse_decorator(urlresolvers.reverse)
"""
In settings.py
"""
SSL_DOMAIN = 'https://example.com'
SSL_SECTIONS = (
'/checkout',
'/account',
)
|
More like this
- SSL Middleware for Webfaction by parlar 6 years ago
- Yet another list partitioning filter by AndrewIngram 4 years ago
- HTTPS redirections middleware with updated URL template tag by xlq 7 months ago
- Transparently encrypt ORM fields using OpenSSL (via M2Crypto) by ncoghlan 1 year, 10 months ago
- Redirect with change list with filters intact with admin actions by AndrewIngram 3 years, 10 months ago
Comments