Задать вопрос

Тел: +7 965 3737 888

545

Просмотров

3

Ответов

breadcrumbs

With this script you can create a simple breadcrumbs line for navigation: Home >> Page >> Subpage ...

Вопрос полезен? Да0/Нет0
file_4435.py(5.0Кб)
None

Ответы (3):

Ответvicpada:29.04.2009
Ответ полезен? Да0/Нет0

Hi, Im just starting to use django.

I didnt get where to exactly put the code for the usage:

Usage: breadcrumbs, default_title = breadcrumbs.get_breadcrumbs(request) breadcrumbs: SafeUnicode HTML String default_title: Unicode String with the name of the current view.

Also, what do you have to put on the template?

Thanks in advance!

Ответguettli:18.03.2009
Ответ полезен? Да0/Нет0

I use breadcrumbs only for user visibles pages. I don't use it for the admin page.

Ответbeetleb:06.12.2008
Ответ полезен? Да0/Нет0

I really like this snippet, and customized it to have my own breadcrumb style (a list rather than the >>> method - better for accessibility).

A more serious problem, but easily rectified, is that it throws an assertion error whenever I access a Django builtin view (such as when I log in). In your test function, you wisely omitted checking the Django views. However, your main function doesn't check.

One whould just write wrapper views to get around this problem - as it'll ensure a breadcrumb still appears on those pages. But that would be a poor idea if one were to use the Django admin. So I had to put in a test for internal Django views in the main code (just a single line and lots of indenting).