django-breadcrumbs-util-1.2
توضیحات
A package that provides a simple way to add breadcrumbs to your Django views
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | django-breadcrumbs-util-1.2 |
| نام | django-breadcrumbs-util |
| نسخه کتابخانه | 1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Hussein Thamer |
| ایمیل نویسنده | hussinthamer211@gmail.com |
| آدرس صفحه اصلی | https://github.com/hosin211/django-breadcrumbs-utils |
| آدرس اینترنتی | https://pypi.org/project/django-breadcrumbs-util/ |
| مجوز | - |
# Django Breadcrumbs Utils
Django Breadcrumbs Utils is a package that provides a simple way to add breadcrumbs to your Django views.
Installation
You can install the package via pip:
## Deployment
To deploy this project run
```python
pip install django-breadcrumbs-utils
```
## Usage
To use the custom_path function from the package, import it into your urls.py file and use it to define your URL patterns:
```python
from breadcrumbs import custom_path
urlpatterns = [
custom_path('my-route/', my_view, name='my-view', breadcrumb='My View'),
# ...
]
```
The custom_path function takes a route argument, a view function, a name argument (optional), and a breadcrumb argument (optional).
The breadcrumb argument should be a string that represents the label of the breadcrumb for the current page.
The custom_path function wraps your view function with a decorator that adds a breadcrumb variable to the context of the view function. The variable contains the breadcrumb label specified in the breadcrumb argument.
## In your template
you can access the breadcrumb variable to display the breadcrumb:
```html
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ breadcrumb }}</li>
</ol>
</nav>
{% endblock %}
```
This will display a breadcrumb trail that starts with a link to the home page and ends with an active breadcrumb label for the current page.
نحوه نصب
نصب پکیج whl django-breadcrumbs-util-1.2:
pip install django-breadcrumbs-util-1.2.whl
نصب پکیج tar.gz django-breadcrumbs-util-1.2:
pip install django-breadcrumbs-util-1.2.tar.gz