Coder Social home page Coder Social logo

marcanuy / django-dynamic-breadcrumbs Goto Github PK

View Code? Open in Web Editor NEW
11.0 5.0 2.0 60 KB

Django app to generate HTML breadcrumbs from URL paths

Home Page: https://django-dynamic-breadcrumbs.readthedocs.io/

License: MIT License

Makefile 2.55% Python 86.90% HTML 10.55%
django breadcrumb breadcrumb-navigation breadcrumbs breadcrumbs-dynamic

django-dynamic-breadcrumbs's Introduction

django-dynamic-breadcrumbs

Django CI Coverage Status PyPI version Code style: black Downloads Documentation Status

django-dynamic-breadcrumbs is a Django app to generate HTML breadcrumbs dynamically from URL paths.

At https://example.com/reference/instrument/guitar/, shows: Home > Reference > Instrument > Guitar.

Quick start

1. Install

pip install django-dynamic-breadcrumbs

2. Add to settings

Add "dynamic_breadcrumbs" label to your INSTALLED_APPS settings:

INSTALLED_APPS = [
    ...
    'dynamic_breadcrumbs',
]

Add dynamic_breadcrumbs.context_processors.breadcrumbs to context_processors:

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [os.path.join(BASE_DIR, "templates")],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
				#...
                "dynamic_breadcrumbs.context_processors.breadcrumbs",
            ],
        },
    },
]

3. Add template

Include the dynamic_breadcrumbs/breadcrumbs.html in your base template.

{% if breadcrumbs %}
<div class="container">
    {% include "dynamic_breadcrumbs/breadcrumbs.html" with breadcrumbs=breadcrumbs%}
</div>
{% endif %}

Now each time you visit a page which makes use of the above template, it will have the breadcrumbs generated from the URL path.

4. (Optional) Customization

Tweak default settings.

Example site

There is an example site to see how it works at example_site. To run it, in example_site directory:

  1. Create db: python manage.py migrate
  2. Load fixtures python manage.py loaddata fixtures.json
  3. Run the server python manage.py runserver

Note: Fixtures were created with a sample database with ./manage.py dumpdata --all --format json -o fixtures.json.

Documentation

Full docs at: https://django-dynamic-breadcrumbs.readthedocs.io/

License

MIT

django-dynamic-breadcrumbs's People

Contributors

marcanuy avatar pescheck-bram avatar williwacker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-dynamic-breadcrumbs's Issues

Change the default html file

Hello!

I am using the dynamic_breadcrumbs in my django project and I like how easy it made it. However I would like to change some styling settings in the dynamic_breadcrumbs/breadcrumbs.html file. Is there a way to override some CSS in it?

Appreciate it
Fadi

Added app verbose_name support

Added some code to show the APP verbose_name instead of the pure app name from the url.
Would be glad if you could implement this change.

Thanks Werner

Pull Request #2

Question about BreadcrumbsItem.get_name

Hi Marcelo,

Thank you for sharing this clever implementation. Of all the breadcrumb implementations I have found so far, yours is by far the simplest to understand and set up and the only one that will allow me to create breadcrumbs of deeply nested re_paths like orgs > 4 > assets > 5 > systems > 5 > components.

I am trying to understand what you were trying to do with the get_name method of the BreadcrumbsItem class. It seemed like it might be a way to address issue #5 but I did not see a way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.