Created
June 29, 2016 04:48
-
-
Save nntndfrk/b444b146ee8268904c44142f92bd5ba9 to your computer and use it in GitHub Desktop.
Django context processors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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