1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from django.core.urlresolvers import set_script_prefix
class ScriptPrefixMiddleware(object):
"""
Set the script prefix for all requests.
Essentially this adds the current request host to all calls to
get_absolute_url(). Much more convenient than adding the schema and
domain manually everywhere.
"""
def process_request(self, request):
schema = 'http://'
if request.is_secure():
schema = 'https://'
host = request.get_host()
if host:
set_script_prefix('%s%s' % (schema, host))
|
More like this
- Create short URL redirects for site urls. by matt.geek.nz 4 years, 3 months ago
- template filter to include protocol and domain in absolute urls by czer 10 months, 2 weeks ago
- quick_url filter by tclineks 5 years ago
- Super User Conditional Page Exception Reporting by zbyte64 4 years, 9 months ago
- Hyperlink list filter by lifefloatsby 5 years, 4 months ago
Comments