I'm writing an application in Django and I want every page to contain a bread crumb.
The bread crum开发者_StackOverflow中文版b needs to look like "Group A > Group A.1 > Group A.1.1". On each page the bread crumb will be different.
Group is a model. The thing confusing me is getting the group object into the context. I am considering writing a context processor that uses a regular expression on the URL to deduce which group object the page is related to. I feel like there is probably a simpler way.
How do I pass this information to the template without specifying these values in every view function? Is there a way for a template's context to figure out where on the site I am?
bread.py
Check out bread.py: http://russell.ballestrini.net/a-homegrown-python-bread-crumb-module/
bread.py is a simple to use python breadcrumb module.
The bread object accepts a url string and grants access to the url crumbs (parts) or url links (list of hrefs to each crumb) .
A demo site exists here to view functionality: http://school.yohdah.com
精彩评论