1 2 3 4 5 6 7 8 9 10 11 12 13 | def url_segments(request):
from urlparse import urlparse
# convert the url path into a list
url_segment = request.path_info.strip("/").split("/")
# assign each segment to it's on var
url_segment_dict = {}
for i in range(len(url_segment)):
url_segment_dict["segment_%d" % (i+1)] = url_segment[i]
return url_segment_dict
|
More like this
- Add site info to request context by bthomas 4 years, 6 months ago
- Template context processor to make the settings.py values available in templates by tamizhgeek 2 years ago
- media_url context variable by marchino 6 years, 1 month ago
- Google Analytics Template Tag by jarofgreen 3 years, 9 months ago
- Private Context Decorator by acdha 3 years, 9 months ago
Comments
Nice primer on how to integrate new template context processors.
#