template filter to include protocol and domain in absolute urls

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django import template
import re

register = template.Library()

@register.filter
def siteabsoluteurl(absoluteurl, request):
	"""
		receives an argument in the form of an absolute url <absoluteurl> 
		Returns the same url with all the necessary path information to be used offsite
	"""
	return request.build_absolute_uri(absoluteurl)

More like this

  1. Absolute URL Templatetag by johnboxall 4 years, 11 months ago
  2. ScriptPrefixMiddleware by shellsage 4 years, 7 months ago
  3. Hyperlink list filter by lifefloatsby 6 years, 3 months ago
  4. favicon Template Tag by benjy_mouse 4 years, 2 months ago
  5. order_by template filter by marinho 5 years, 11 months ago

Comments

(Forgotten your password?)