Login

Tag "get_absolute_url"

Snippet List

template filter to include protocol and domain in absolute urls

I created this template filter to be able to use get_absolute_url in an email template. Save the code into /templatetags/navigation.py Use like this: {% load navigation %} {{ instance.get_absolute_url|siteabsoluteurl:request }}

  • template
  • filter
  • templatetag
  • template-filter
  • url
  • template-filters
  • get_absolute_url
  • templatefilter
  • absolute
Read More

ScriptPrefixMiddleware

Adds http://hostname or https://hostname before every URL generated by a Django url function. **Example:** Normally, something like YourModel().get_absolute_url() would return `/2009/09/02/slug`. However, this is not an absolute URL, because it does not include an HTTP schema or host. With this middleware, YourModel().get_absolute_url() will return `http://yourdomain.com/2009/09/02/slug`. This will also work for calls to reverse() or the {% url %} template tag. **Installation:** Drop this code into yourproject/middleware/scriptprefix.py. **Usage:** In your settings.py, add: MIDDLEWARE_CLASSES = ( # ... 'yourproject.middleware.scriptprefix.ScriptPrefixMiddleware', # ... )

  • url
  • domain
  • get_absolute_url
  • host
  • set_script_prefix
Read More

quick_url filter

A simple filter that generates a url from an object that has a get_absolute_url method. {{ object|quick_url }} a previous, simpler approach: [#511](http://www.djangosnippets.org/snippets/511/)

  • filter
  • get_absolute_url
  • quick_url
Read More

3 snippets posted so far.