Skip to content

Instantly share code, notes, and snippets.

@nntndfrk
Created June 29, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nntndfrk/b444b146ee8268904c44142f92bd5ba9 to your computer and use it in GitHub Desktop.
Save nntndfrk/b444b146ee8268904c44142f92bd5ba9 to your computer and use it in GitHub Desktop.
Django context processors
Quick and simple, but not good for production:
(in a view)
request.scheme # http or https
request.META['HTTP_HOST'] # example.com
request.path # /some/content/1/
(in a template)
{{ request.scheme }} :// {{ request.META.HTTP_HOST }} {{ request.path }}
Be sure to use a RequestContext, which is the case if you're using render.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment