Metadata-Version: 2.4
Name: DjangoContextActions
Version: 0.0.7
Summary: Simply add context related links to your Django views.
License: AGPLv3+
License-File: LICENSE
Author: Fabian Becker
Author-email: info@alertrix.net
Requires-Python: >=3.12,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: Django (>=6.0.0)
Description-Content-Type: text/markdown

# Django Context-Actions

Quickly link to other pages of your django application.

## Features

- Simple definition of links to other pages
- Static or dynamic definition of ContextActions
- Filters out links to views that the user is not allowed to access
- Automatically uses the most recent `next` parameter of GET queries

## Setup

```python
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView

from contextactions.contextactions import ContextAction
from contextactions.mixins import ContextActionsMixin


class MyView(
    ContextActionsMixin,
    TemplateView,
):
    context_actions = [
        ContextAction(
            name='my_app:my_view',
            label=_('my human readable translated link text'),
        ),
    ]
    template_name = 'my_template.html'
```

In your template include the provided context actions template…
```html
{% include 'contextactions/contextactions.html' %}
```
or implement you own using view.get_context_actions
```html
{% for action in view.get_context_actions %}
    <a href="{% if action.url %}{{ action.url }}{% else %}{% url action.name %}{% endif %}">{% if action.label %}{{ action.label }}{% else %}{{ action.url }}{% endif %}</a>
{% endfor %}
```

