{"id":20689981,"url":"https://github.com/tj-django/django-view-breadcrumbs","last_synced_at":"2025-04-13T00:48:45.317Z","repository":{"id":37700840,"uuid":"118060183","full_name":"tj-django/django-view-breadcrumbs","owner":"tj-django","description":"Breadcrumb mixins for django views. Create breadcrumbs in seconds.","archived":false,"fork":false,"pushed_at":"2025-04-02T21:50:23.000Z","size":968,"stargazers_count":78,"open_issues_count":11,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T00:48:39.053Z","etag":null,"topics":["breadcrumb-mixin","breadcrumb-mixins","breadcrumbs","breadcrumbs-template","custom-crumbs","customview","detailview","django","django-bootstrap-breadcrumbs","django-breadcrumbs","django-views","listview","sample-crumbs","translation-support","urlpatterns"],"latest_commit_sha":null,"homepage":"https://tj-django.github.io/django-view-breadcrumbs/#/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tj-django.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jackton1","patreon":null,"open_collective":"tj-django","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":[]}},"created_at":"2018-01-19T01:30:27.000Z","updated_at":"2025-04-05T14:32:47.000Z","dependencies_parsed_at":"2024-02-13T01:41:52.256Z","dependency_job_id":"0224d01d-0a93-4760-8a5d-dfddb14b205a","html_url":"https://github.com/tj-django/django-view-breadcrumbs","commit_stats":{"total_commits":989,"total_committers":15,"mean_commits":65.93333333333334,"dds":0.5894843276036401,"last_synced_commit":"b24460fcee0fda371f9b4bdf562df613d9d141d4"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-view-breadcrumbs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-view-breadcrumbs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-view-breadcrumbs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-view-breadcrumbs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj-django","download_url":"https://codeload.github.com/tj-django/django-view-breadcrumbs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650436,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["breadcrumb-mixin","breadcrumb-mixins","breadcrumbs","breadcrumbs-template","custom-crumbs","customview","detailview","django","django-bootstrap-breadcrumbs","django-breadcrumbs","django-views","listview","sample-crumbs","translation-support","urlpatterns"],"created_at":"2024-11-16T23:11:29.780Z","updated_at":"2025-04-13T00:48:45.293Z","avatar_url":"https://github.com/tj-django.png","language":"Python","funding_links":["https://github.com/sponsors/jackton1","https://opencollective.com/tj-django","https://www.buymeacoffee.com/jackton1"],"categories":[],"sub_categories":[],"readme":"# django-view-breadcrumbs\n\n[![Test](https://github.com/tj-django/django-view-breadcrumbs/actions/workflows/test.yml/badge.svg)](https://github.com/tj-django/django-view-breadcrumbs/actions/workflows/test.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/537b0ce56e744f078f17cc8ccd4200d8)](https://www.codacy.com/gh/tj-django/django-view-breadcrumbs/dashboard?utm_source=github.com\\\u0026utm_medium=referral\\\u0026utm_content=tj-django/django-view-breadcrumbs\\\u0026utm_campaign=Badge_Grade) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/tj-django/django-view-breadcrumbs/main.svg)](https://results.pre-commit.ci/latest/github/tj-django/django-view-breadcrumbs/main) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/537b0ce56e744f078f17cc8ccd4200d8)](https://www.codacy.com/gh/tj-django/django-view-breadcrumbs/dashboard?utm_source=github.com\\\u0026utm_medium=referral\\\u0026utm_content=tj-django/django-view-breadcrumbs\\\u0026utm_campaign=Badge_Coverage) [![PyPI version](https://badge.fury.io/py/django-view-breadcrumbs.svg)](https://badge.fury.io/py/django-view-breadcrumbs)\n\n![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-view-breadcrumbs) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-view-breadcrumbs)\n[![Downloads](https://static.pepy.tech/badge/django-view-breadcrumbs)](https://pepy.tech/project/django-view-breadcrumbs)\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n## Table of Contents\n\n*   [Background](#background)\n*   [Installation](#installation)\n    *   [Add `view_breadcrumbs` to your INSTALLED\\_APPS](#add-view_breadcrumbs-to-your-installed_apps)\n*   [Breadcrumb mixin classes provided.](#breadcrumb-mixin-classes-provided)\n*   [Settings](#settings)\n    *   [Customization](#customization)\n        *   [BREADCRUMBS\\_TEMPLATE](#breadcrumbs_template)\n            *   [Site wide](#site-wide)\n            *   [Overriding the breadcrumb template for a single view](#overriding-the-breadcrumb-template-for-a-single-view)\n        *   [BREADCRUMBS\\_HOME\\_LABEL](#breadcrumbs_home_label)\n            *   [Site wide](#site-wide-1)\n            *   [Overriding the Home label for a specific view](#overriding-the-home-label-for-a-specific-view)\n*   [Translation support](#translation-support)\n    *   [Example](#example)\n*   [Usage](#usage)\n    *   [View Configuration](#view-configuration)\n        *   [django-tables-2](#django-tables-2)\n    *   [URL Configuration](#url-configuration)\n    *   [Examples](#examples)\n        *   [Sample crumbs: `Posts`](#sample-crumbs-posts)\n        *   [Sample crumbs:  `Home / Posts / Test - Post`](#sample-crumbs--home--posts--test---post)\n        *   [Custom crumbs: `Home / My Test Breadcrumb`](#custom-crumbs-home--my-test-breadcrumb)\n    *   [Using multiple apps](#using-multiple-apps)\n*   [Running locally](#running-locally)\n*   [Credits](#credits)\n*   [Contributors ✨](#contributors-)\n\n## Background\n\nThis package provides a set of breadcrumb mixin classes that can be added to any django class based view and requires adding just `{% render_breadcrumbs %}` to the base template.\n\n\u003cimg width=\"1438\" alt=\"breadcrumbs\" src=\"https://user-images.githubusercontent.com/17484350/128493747-776706bf-d46c-4b57-ba54-c64fcc71ada7.png\"\u003e\n\nIn the `base.html` template add the `render_breadcrumbs` tag and any template that inherits the base should have breadcrumbs included.\n\n**Example:**\n\n    my_app\n       |--templates\n                |--base.html\n                |--create.html\n\n`base.html`\n\n```jinja2\n{% load view_breadcrumbs %}\n\n{% block breadcrumbs %}\n    {% render_breadcrumbs %} {# Optionally provide a custom template e.g {% render_breadcrumbs \"view_breadcrumbs/bootstrap5.html\" %} #}\n{% endblock %}\n```\n\nAnd your `create.html`.\n\n```jinja2\n{% extends \"base.html\" %}\n```\n\n## Installation\n\n```bash\n$ pip install django-view-breadcrumbs\n\n```\n\n### Add `view_breadcrumbs` to your INSTALLED\\_APPS\n\n```python\n\nINSTALLED_APPS = [\n    ...,\n    \"view_breadcrumbs\",\n    ...,\n]\n```\n\n## Breadcrumb mixin classes provided.\n\n*   `BaseBreadcrumbMixin`    - Subclasses requires a `crumbs` class property.\n*   `CreateBreadcrumbMixin`  - For create views `Home / Posts / Add Post`\n*   `DetailBreadcrumbMixin`  - For detail views `Home / Posts / Post 1`\n*   `ListBreadcrumbMixin`    - For list views `Home / Posts`\n*   `UpdateBreadcrumbMixin`  - For Update views `Home / Posts / Post 1 / Update Post 1`\n*   `DeleteBreadcrumbMixin`  - For Delete views this has a link to the list view to be used as the success URL.\n\n## Settings\n\n\u003e NOTE :warning:\n\u003e\n\u003e *   Make sure that `\"django.template.context_processors.request\"` is added to your TEMPLATE OPTIONS setting.\n\n```python\nTEMPLATES  = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\", # \u003c- This context processor is required\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n```\n\nModify the defaults using the following:\n\n| Name                       | Default                                     | Description |    Options          |\n|----------------------------|---------------------------------------------|-------------|---------------------|\n| `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)                 |\n| `BREADCRUMBS_HOME_LABEL`   |  `Home`                                     |  Default label for the root path  |         |\n\n### Customization\n\n#### BREADCRUMBS\\_TEMPLATE\n\n##### Site wide\n\n```python\nBREADCRUMBS_TEMPLATE = \"my_app/breadcrumbs.html\"\n```\n\n##### Overriding the breadcrumb template for a single view\n\nUpdate the `base.html`\n\n```jinja2\n{% render_breadcrumbs \"my_app/breadcrumbs.html\" %}\n```\n\n#### BREADCRUMBS\\_HOME\\_LABEL\n\n##### Site wide\n\n```python\nBREADCRUMBS_HOME_LABEL = \"My new home\"\n```\n\n##### Overriding the Home label for a specific view\n\n```python\nfrom django.utils.translation import gettext_lazy as _\nfrom view_breadcrumbs import DetailBreadcrumbMixin\nfrom django.views.generic import DetailView\nfrom demo.models import TestModel\n\n\nclass TestDetailView(DetailBreadcrumbMixin, DetailView):\n     model = TestModel\n     home_label = _(\"My new home\")\n     template_name = \"demo/test-detail.html\"\n```\n\n*Renders*\n\n\u003cimg width=\"436\" alt=\"custom-root-breadcrumb\" src=\"https://user-images.githubusercontent.com/17484350/128493798-c71a8071-e913-4875-80b6-c7b414ac4e24.png\"\u003e\n\n## [Translation support](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/)\n\n### Example\n\n![translated-crumbs](https://user-images.githubusercontent.com/17484350/128493830-7e50a6a9-3648-48cb-b198-4646ee2b03cf.png)\n\n## Usage\n\n`django-view-breadcrumbs` includes generic mixins that can be added to a class based view.\n\nUsing the generic breadcrumb mixin each breadcrumb will be added to the view dynamically\nand can be overridden by providing a `crumbs` property.\n\n### View Configuration\n\n\u003e NOTE: :warning:\n\u003e\n\u003e *   Model based views should use a pattern `view_name=model_verbose_name_{action}`\n\n|  Actions  |  View Class |  View name  | Sample Breadcrumb | Example  |\n|-----------|-------------|-------------|-------------------|----------|\n| `list`    | [`ListView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#listview)  | `{model.verbose_name}_list` |  `Home / Posts`  |  [Posts Example](https://github.com/tj-django/django-view-breadcrumbs#sample-crumbs-posts) |\n| `create`  | [`CreateView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#createview) | `{model.verbose_name}_create` | `Home / Posts / Add Post` |  |\n| `detail`  | [`DetailView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-display/#detailview) | `{model.verbose_name}_detail` | `Home / Posts / Test - Post` |  |\n| `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` |  |\n| `delete`  | [`DeleteView`](https://docs.djangoproject.com/en/3.2/ref/class-based-views/generic-editing/#deleteview) | `{model.verbose_name}_delete` | N/A |\n|   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|   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|   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|   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) |\n\n#### [django-tables-2](https://django-tables2.readthedocs.io/en/latest/index.html#)\n\n|  Actions  |  View Class |  View name  | Sample Breadcrumb | Example  |\n|-----------|-------------|-------------|-------------------|----------|\n|   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|   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|   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` |\n\nFor more examples see: [demo app](https://github.com/tj-django/django-view-breadcrumbs/tree/main/demo)\n\n### URL Configuration\n\nBased 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.\n\nThis can be manually entered in your `urls.py` or you can optionally use the following class properties instead of hardcoding the `view_name`.\n\n```python\n...\n    path(\"tests/\", TestListsView.as_view(), name=TestListsView.list_view_name),\n    path(\n        \"tests/\u003cslug:slug\u003e/\",\n        TestDetailView.as_view(),\n        name=TestDetailView.detail_view_name,\n    ),\n    path(\n        \"tests/\u003cslug:slug\u003e/update/\",\n        TestUpdateView.as_view(),\n        name=TestUpdateView.update_view_name,\n    ),\n    path(\n        \"tests/\u003cslug:slug\u003e/delete/\",\n        TestDeleteView.as_view(),\n        name=TestDeleteView.delete_view_name,\n    ),\n...\n```\n\n### Examples\n\n#### Sample crumbs: `Posts`\n\nIn your urls.py\n\n```python\n  urlpatterns = [\n      ...\n      path(\"posts/\", views.PostList.as_view(), name=\"post_list\"),\n      ...\n      # OR\n      ...\n      path(\"posts/\", views.PostList.as_view(), name=views.PostList.list_view_name),\n      ...\n  ]\n```\n\n\u003e All crumbs use the home root path `/` as the base this can be excluded by specifying `add_home = False`\n\n```python\nfrom django.views.generic import ListView\nfrom view_breadcrumbs import ListBreadcrumbMixin\n\n\nclass PostList(ListBreadcrumbMixin, ListView):\n    model = Post\n    template_name = \"app/post/list.html\"\n    add_home = False\n```\n\n#### Sample crumbs:  `Home / Posts / Test - Post`\n\nIn your `urls.py`\n\n```python\n  urlpatterns = [\n      ...\n      path(\"posts/\u003cslug:slug\u003e/\", views.PostDetail.as_view(), name=\"post_detail\"),\n      ...\n      # OR\n      ...\n      path(\"posts/\u003cslug:slug\u003e/\", views.PostDetail.as_view(), name=views.PostDetail.detail_view_name),\n      ...\n  ]\n\n```\n\n`views.py`\n\n```python\nfrom django.views.generic import DetailView\nfrom view_breadcrumbs import DetailBreadcrumbMixin\n\n\nclass PostDetail(DetailBreadcrumbMixin, DetailView):\n    model = Post\n    template_name = \"app/post/detail.html\"\n    breadcrumb_use_pk = False\n```\n\n#### Custom crumbs: `Home / My Test Breadcrumb`\n\nURL configuration.\n\n```python\n    urlpatterns = [\n       path(\"my-custom-view/\", views.CustomView.as_view(), name=\"custom_view\"),\n    ]\n```\n\nviews.py\n\n```python\nfrom django.urls import reverse\nfrom django.views.generic import View\nfrom view_breadcrumbs import BaseBreadcrumbMixin\nfrom demo.models import TestModel\n\n\nclass CustomView(BaseBreadcrumbMixin, View):\n    model = TestModel\n    template_name = \"app/test/custom.html\"\n    crumbs = [(\"My Test Breadcrumb\", reverse(\"custom_view\"))]  # OR reverse_lazy\n```\n\n**OR**\n\n```python\nfrom django.urls import reverse\nfrom django.views.generic import View\nfrom view_breadcrumbs import BaseBreadcrumbMixin\nfrom demo.models import TestModel\nfrom django.utils.functional import cached_property\n\n\nclass CustomView(BaseBreadcrumbMixin, View):\n    template_name = \"app/test/custom.html\"\n\n    @cached_property\n    def crumbs(self):\n        return [(\"My Test Breadcrumb\", reverse(\"custom_view\"))]\n\n```\n\n\u003e Refer to the [demo app](https://github.com/tj-django/django-view-breadcrumbs/tree/main/demo) for more examples.\n\n### Using multiple apps\n\nTo reference models from a different application you need to override the `app_name` class attribute.\n\nExample:\nUsing a `Library` model that is imported from a `custom` application that you want to render in a `demo` app view.\n\n```python\nINSTALLED_APPS =  [\n    ...\n    \"demo\",\n    \"custom\",\n    ...\n]\n```\n\n`demo/views.py`\n\n```python\nclass LibraryDetailView(DetailBreadcrumbMixin, DetailView):\n    model = Library\n    app_name = \"demo\"\n    ...\n```\n\n## Running locally\n\n```bash\n$ git clone git@github.com:tj-django/django-view-breadcrumbs.git\n$ make install-dev\n$ make migrate\n$ make run\n```\n\nSpins up a django server running the demo app.\n\nVisit `http://127.0.0.1:8090`\n\n## Credits\n\n*   [django-bootstrap-breadcrumbs](https://github.com/prymitive/bootstrap-breadcrumbs)\n\nTo file a bug or submit a patch, please head over to [django-view-breadcrumbs on github](https://github.com/tj-django/django-view-breadcrumbs/issues).\n\nIf you feel generous and want to show some extra appreciation:\n\nSupport me with a :star:\n\n[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]\n\n[buymeacoffee]: https://www.buymeacoffee.com/jackton1\n\n[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n\n\u003c!-- markdownlint-disable --\u003e\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://fansourcedpoisontour.com\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1037197?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDerek\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/tj-django/django-view-breadcrumbs/commits?author=KrunchMuffin\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://www.emencia.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1572165?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDavid THENON\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/tj-django/django-view-breadcrumbs/commits?author=sveetch\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-django%2Fdjango-view-breadcrumbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj-django%2Fdjango-view-breadcrumbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-django%2Fdjango-view-breadcrumbs/lists"}