In the `base.html` template add the `render_breadcrumbs` tag and any template that inherits the base should have breadcrumbs included.
**Example:**
my_app
|--templates
|--base.html
|--create.html
`base.html`
```jinja2
{% load view_breadcrumbs %}
{% block breadcrumbs %}
{% render_breadcrumbs %} {# Optionally provide a custom template e.g {% render_breadcrumbs "view_breadcrumbs/bootstrap5.html" %} #}
{% endblock %}
```
And your `create.html`.
```jinja2
{% extends "base.html" %}
```
## Installation
```bash
$ pip install django-view-breadcrumbs
```
### Add `view_breadcrumbs` to your INSTALLED\_APPS
```python
INSTALLED_APPS = [
...,
"view_breadcrumbs",
...,
]
```
## Breadcrumb mixin classes provided.
* `BaseBreadcrumbMixin` - Subclasses requires a `crumbs` class property.
* `CreateBreadcrumbMixin` - For create views `Home / Posts / Add Post`
* `DetailBreadcrumbMixin` - For detail views `Home / Posts / Post 1`
* `ListBreadcrumbMixin` - For list views `Home / Posts`
* `UpdateBreadcrumbMixin` - For Update views `Home / Posts / Post 1 / Update Post 1`
* `DeleteBreadcrumbMixin` - For Delete views this has a link to the list view to be used as the success URL.
## Settings
> NOTE :warning:
>
> * Make sure that `"django.template.context_processors.request"` is added to your TEMPLATE OPTIONS setting.
```python
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request", # <- This context processor is required
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
```
Modify the defaults using the following:
| Name | Default | Description | Options |
|----------------------------|---------------------------------------------|-------------|---------------------|
| `BREADCRUMBS_TEMPLATE` | `"view_breadcrumbs/bootstrap5.html"` | Template used to render breadcrumbs. | [Predefined Templates](https://github.com/tj-django/django-view-breadcrumbs/tree/main/view_breadcrumbs/templates/view_breadcrumbs) |
| `BREADCRUMBS_HOME_LABEL` | `Home` | Default label for the root path | |
### Customization
#### BREADCRUMBS\_TEMPLATE
##### Site wide
```python
BREADCRUMBS_TEMPLATE = "my_app/breadcrumbs.html"
```
##### Overriding the breadcrumb template for a single view
Update the `base.html`
```jinja2
{% render_breadcrumbs "my_app/breadcrumbs.html" %}
```
#### BREADCRUMBS\_HOME\_LABEL
##### Site wide
```python
BREADCRUMBS_HOME_LABEL = "My new home"
```
##### Overriding the Home label for a specific view
```python
from django.utils.translation import gettext_lazy as _
from view_breadcrumbs import DetailBreadcrumbMixin
from django.views.generic import DetailView
from demo.models import TestModel
class TestDetailView(DetailBreadcrumbMixin, DetailView):
model = TestModel
home_label = _("My new home")
template_name = "demo/test-detail.html"
```
*Renders*
## [Translation support](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/)
### Example

## Usage
`django-view-breadcrumbs` includes generic mixins that can be added to a class based view.
Using the generic breadcrumb mixin each breadcrumb will be added to the view dynamically
and can be overridden by providing a `crumbs` property.
### View Configuration
> NOTE: :warning:
>
> * Model based views should use a pattern `view_name=model_verbose_name_{action}`
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| `list` | [`ListView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#listview) | `{model.verbose_name}_list` | `Home / Posts` | |
| `create` | [`CreateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#createview) | `{model.verbose_name}_create` | `Home / Posts / Add Post` | |
| `detail` | [`DetailView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#detailview) | `{model.verbose_name}_detail` | `Home / Posts / Test - Post` | |
| `change` | [`UpdateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#updateview) | `{model.verbose_name}_update` | `Home / Posts / Test - Post / Update Test - Post` | |
| `delete` | [`DeleteView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#deleteview) | `{model.verbose_name}_delete` | N/A |
| N/A | [`TemplateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#templateview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`FormView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#formview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`AboutView`](https://docs.djangoproject.com/en/3.2/topics/class-based-views/#subclassing-generic-views) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`View`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#view) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
#### [django-tables-2](https://django-tables2.readthedocs.io/en/latest/index.html#)
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| N/A | [`SingleTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#a-single-table-using-singletablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L154-L162) |
| N/A | [`MultiTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#multiple-tables-using-multitablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L166-L173) |
| N/A | [`SingleTableView`](https://django-tables2.readthedocs.io/en/latest/pages/api-reference.html?highlight=SingleTableView#singletableview) | N/A | N/A | Same implementation as `SingleTableMixin` |
For more examples see: [demo app](https://github.com/tj-django/django-view-breadcrumbs/tree/main/demo)
### URL Configuration
Based on the table of actions listed above there's a strict `view_name` requirement that needs to be adhered to in order for breadcrumbs to work.
This can be manually entered in your `urls.py` or you can optionally use the following class properties instead of hardcoding the `view_name`.
```python
...
path("tests/", TestListsView.as_view(), name=TestListsView.list_view_name),
path(
"tests/Derek 📖 |
David THENON 💻 |
In the `base.html` template add the `render_breadcrumbs` tag and any template that inherits the base should have breadcrumbs included.
**Example:**
my_app
|--templates
|--base.html
|--create.html
`base.html`
```jinja2
{% load view_breadcrumbs %}
{% block breadcrumbs %}
{% render_breadcrumbs %} {# Optionally provide a custom template e.g {% render_breadcrumbs "view_breadcrumbs/bootstrap5.html" %} #}
{% endblock %}
```
And your `create.html`.
```jinja2
{% extends "base.html" %}
```
## Installation
```bash
$ pip install django-view-breadcrumbs
```
### Add `view_breadcrumbs` to your INSTALLED\_APPS
```python
INSTALLED_APPS = [
...,
"view_breadcrumbs",
...,
]
```
## Breadcrumb mixin classes provided.
* `BaseBreadcrumbMixin` - Subclasses requires a `crumbs` class property.
* `CreateBreadcrumbMixin` - For create views `Home / Posts / Add Post`
* `DetailBreadcrumbMixin` - For detail views `Home / Posts / Post 1`
* `ListBreadcrumbMixin` - For list views `Home / Posts`
* `UpdateBreadcrumbMixin` - For Update views `Home / Posts / Post 1 / Update Post 1`
* `DeleteBreadcrumbMixin` - For Delete views this has a link to the list view to be used as the success URL.
## Settings
> NOTE :warning:
>
> * Make sure that `"django.template.context_processors.request"` is added to your TEMPLATE OPTIONS setting.
```python
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request", # <- This context processor is required
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
```
Modify the defaults using the following:
| Name | Default | Description | Options |
|----------------------------|---------------------------------------------|-------------|---------------------|
| `BREADCRUMBS_TEMPLATE` | `"view_breadcrumbs/bootstrap5.html"` | Template used to render breadcrumbs. | [Predefined Templates](https://github.com/tj-django/django-view-breadcrumbs/tree/main/view_breadcrumbs/templates/view_breadcrumbs) |
| `BREADCRUMBS_HOME_LABEL` | `Home` | Default label for the root path | |
### Customization
#### BREADCRUMBS\_TEMPLATE
##### Site wide
```python
BREADCRUMBS_TEMPLATE = "my_app/breadcrumbs.html"
```
##### Overriding the breadcrumb template for a single view
Update the `base.html`
```jinja2
{% render_breadcrumbs "my_app/breadcrumbs.html" %}
```
#### BREADCRUMBS\_HOME\_LABEL
##### Site wide
```python
BREADCRUMBS_HOME_LABEL = "My new home"
```
##### Overriding the Home label for a specific view
```python
from django.utils.translation import gettext_lazy as _
from view_breadcrumbs import DetailBreadcrumbMixin
from django.views.generic import DetailView
from demo.models import TestModel
class TestDetailView(DetailBreadcrumbMixin, DetailView):
model = TestModel
home_label = _("My new home")
template_name = "demo/test-detail.html"
```
*Renders*
## [Translation support](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/)
### Example

## Usage
`django-view-breadcrumbs` includes generic mixins that can be added to a class based view.
Using the generic breadcrumb mixin each breadcrumb will be added to the view dynamically
and can be overridden by providing a `crumbs` property.
### View Configuration
> NOTE: :warning:
>
> * Model based views should use a pattern `view_name=model_verbose_name_{action}`
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| `list` | [`ListView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#listview) | `{model.verbose_name}_list` | `Home / Posts` | |
| `create` | [`CreateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#createview) | `{model.verbose_name}_create` | `Home / Posts / Add Post` | |
| `detail` | [`DetailView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#detailview) | `{model.verbose_name}_detail` | `Home / Posts / Test - Post` | |
| `change` | [`UpdateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#updateview) | `{model.verbose_name}_update` | `Home / Posts / Test - Post / Update Test - Post` | |
| `delete` | [`DeleteView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#deleteview) | `{model.verbose_name}_delete` | N/A |
| N/A | [`TemplateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#templateview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`FormView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#formview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`AboutView`](https://docs.djangoproject.com/en/3.2/topics/class-based-views/#subclassing-generic-views) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`View`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#view) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
#### [django-tables-2](https://django-tables2.readthedocs.io/en/latest/index.html#)
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| N/A | [`SingleTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#a-single-table-using-singletablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L154-L162) |
| N/A | [`MultiTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#multiple-tables-using-multitablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L166-L173) |
| N/A | [`SingleTableView`](https://django-tables2.readthedocs.io/en/latest/pages/api-reference.html?highlight=SingleTableView#singletableview) | N/A | N/A | Same implementation as `SingleTableMixin` |
For more examples see: [demo app](https://github.com/tj-django/django-view-breadcrumbs/tree/main/demo)
### URL Configuration
Based on the table of actions listed above there's a strict `view_name` requirement that needs to be adhered to in order for breadcrumbs to work.
This can be manually entered in your `urls.py` or you can optionally use the following class properties instead of hardcoding the `view_name`.
```python
...
path("tests/", TestListsView.as_view(), name=TestListsView.list_view_name),
path(
"tests/Derek 📖 |
David THENON 💻 |
In the `base.html` template add the `render_breadcrumbs` tag and any template that inherits the base should have breadcrumbs included.
**Example:**
my_app
|--templates
|--base.html
|--create.html
`base.html`
```jinja2
{% load view_breadcrumbs %}
{% block breadcrumbs %}
{% render_breadcrumbs %} {# Optionally provide a custom template e.g {% render_breadcrumbs "view_breadcrumbs/bootstrap5.html" %} #}
{% endblock %}
```
And your `create.html`.
```jinja2
{% extends "base.html" %}
```
## Installation
```bash
$ pip install django-view-breadcrumbs
```
### Add `view_breadcrumbs` to your INSTALLED\_APPS
```python
INSTALLED_APPS = [
...,
"view_breadcrumbs",
...,
]
```
## Breadcrumb mixin classes provided.
* `BaseBreadcrumbMixin` - Subclasses requires a `crumbs` class property.
* `CreateBreadcrumbMixin` - For create views `Home / Posts / Add Post`
* `DetailBreadcrumbMixin` - For detail views `Home / Posts / Post 1`
* `ListBreadcrumbMixin` - For list views `Home / Posts`
* `UpdateBreadcrumbMixin` - For Update views `Home / Posts / Post 1 / Update Post 1`
* `DeleteBreadcrumbMixin` - For Delete views this has a link to the list view to be used as the success URL.
## Settings
> NOTE :warning:
>
> * Make sure that `"django.template.context_processors.request"` is added to your TEMPLATE OPTIONS setting.
```python
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request", # <- This context processor is required
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
```
Modify the defaults using the following:
| Name | Default | Description | Options |
|----------------------------|---------------------------------------------|-------------|---------------------|
| `BREADCRUMBS_TEMPLATE` | `"view_breadcrumbs/bootstrap5.html"` | Template used to render breadcrumbs. | [Predefined Templates](https://github.com/tj-django/django-view-breadcrumbs/tree/main/view_breadcrumbs/templates/view_breadcrumbs) |
| `BREADCRUMBS_HOME_LABEL` | `Home` | Default label for the root path | |
### Customization
#### BREADCRUMBS\_TEMPLATE
##### Site wide
```python
BREADCRUMBS_TEMPLATE = "my_app/breadcrumbs.html"
```
##### Overriding the breadcrumb template for a single view
Update the `base.html`
```jinja2
{% render_breadcrumbs "my_app/breadcrumbs.html" %}
```
#### BREADCRUMBS\_HOME\_LABEL
##### Site wide
```python
BREADCRUMBS_HOME_LABEL = "My new home"
```
##### Overriding the Home label for a specific view
```python
from django.utils.translation import gettext_lazy as _
from view_breadcrumbs import DetailBreadcrumbMixin
from django.views.generic import DetailView
from demo.models import TestModel
class TestDetailView(DetailBreadcrumbMixin, DetailView):
model = TestModel
home_label = _("My new home")
template_name = "demo/test-detail.html"
```
*Renders*
## [Translation support](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/)
### Example

## Usage
`django-view-breadcrumbs` includes generic mixins that can be added to a class based view.
Using the generic breadcrumb mixin each breadcrumb will be added to the view dynamically
and can be overridden by providing a `crumbs` property.
### View Configuration
> NOTE: :warning:
>
> * Model based views should use a pattern `view_name=model_verbose_name_{action}`
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| `list` | [`ListView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#listview) | `{model.verbose_name}_list` | `Home / Posts` | |
| `create` | [`CreateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#createview) | `{model.verbose_name}_create` | `Home / Posts / Add Post` | |
| `detail` | [`DetailView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#detailview) | `{model.verbose_name}_detail` | `Home / Posts / Test - Post` | |
| `change` | [`UpdateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#updateview) | `{model.verbose_name}_update` | `Home / Posts / Test - Post / Update Test - Post` | |
| `delete` | [`DeleteView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#deleteview) | `{model.verbose_name}_delete` | N/A |
| N/A | [`TemplateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#templateview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`FormView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#formview) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`AboutView`](https://docs.djangoproject.com/en/3.2/topics/class-based-views/#subclassing-generic-views) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
| N/A | [`View`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/base/#view) | N/A | N/A | See: [Custom View](#custom-crumbs-home--my-test-breadcrumb) |
#### [django-tables-2](https://django-tables2.readthedocs.io/en/latest/index.html#)
| Actions | View Class | View name | Sample Breadcrumb | Example |
|-----------|-------------|-------------|-------------------|----------|
| N/A | [`SingleTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#a-single-table-using-singletablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L154-L162) |
| N/A | [`MultiTableMixin`](https://django-tables2.readthedocs.io/en/latest/pages/generic-mixins.html?highlight=SingleTableMixin#multiple-tables-using-multitablemixin) | N/A | N/A | See: [demo table view](https://github.com/tj-django/django-view-breadcrumbs/blob/main/demo/views.py#L166-L173) |
| N/A | [`SingleTableView`](https://django-tables2.readthedocs.io/en/latest/pages/api-reference.html?highlight=SingleTableView#singletableview) | N/A | N/A | Same implementation as `SingleTableMixin` |
For more examples see: [demo app](https://github.com/tj-django/django-view-breadcrumbs/tree/main/demo)
### URL Configuration
Based on the table of actions listed above there's a strict `view_name` requirement that needs to be adhered to in order for breadcrumbs to work.
This can be manually entered in your `urls.py` or you can optionally use the following class properties instead of hardcoding the `view_name`.
```python
...
path("tests/", TestListsView.as_view(), name=TestListsView.list_view_name),
path(
"tests/Derek 📖 |
David THENON 💻 |