Dynamic breadcumbs

In my application I’ve got the following class-based view:

class LabelListView(ListView):
model = Label
template_name = ‘edges/label_list.html’

In the template edges/label_list.html I would like to dynamically render breadcrumbs, is it possible to return something like key-value pairs from the LabelListView to the template.

They are basically key-value pairs:
‘home’, Home
‘label-list’, Label list
‘add-label’, Add label

Kind regards,


First, a side note. You don’t “return values to a template.” The view is the active component here, the template is just that - a template from which (usually) HTML is generated. It’s an important issue of perspective to keep in mind.

The view calls a rendering engine to convert a template with its context to a response.

Your view is responsible for building the context. That context is the data used by the rendering engine to render the template.

What does that mean here? It means that you can add anything you want to the context in your view.

When referring to one of the system-provided Class Based Views, this means overriding the get_context_data method to add data to the context for being rendered. (You then need to modify the template to use that data.)

If you’re not familiar with how the CBVs work, I always recommend becoming familiar with the Classy Class Based View site along with the CBV diagrams page. They’ve helped me a lot with understanding how the CBVs work.

Hi Ken,

Thanks for your reply.

You’re explanation made a few pennies drop.

The content of the sites you reference is very helpful.

Kind regards,