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 GET parameter tag by marltu 1 year, 7 months ago
- Add site info to request context by bthomas 3 years, 2 months ago
- Load static media from secure (SSL) static server (Context Processor) by ianreardon 2 years, 4 months ago
- media_url context variable by marchino 4 years, 10 months ago
- Context processor for django admin app_list by alexander 1 year, 12 months ago
Comments
Nice primer on how to integrate new template context processors.
#