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 ago
  2. Add site info to request context by bthomas 4 years, 6 months ago
  3. ScriptPrefixMiddleware by shellsage 3 years, 8 months ago
  4. getattr template filter by joshua 6 years, 2 months ago
  5. Template-Filter for Feedparser-Dates by kioopi 3 years, 11 months ago

Comments

(Forgotten your password?)