2

I'm writing an application in Django and I want every page to contain a bread crumb.

The bread crumb 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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
hekevintran
  • 22,822
  • 32
  • 111
  • 180

1 Answers1

0

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