Skip to main content

Simply add context related links to your Django views.

Project description

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

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…

{% include 'contextactions/contextactions.html' %}

or implement you own using view.get_context_actions

{% 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 %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocontextactions-0.0.6.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djangocontextactions-0.0.6-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file djangocontextactions-0.0.6.tar.gz.

File metadata

  • Download URL: djangocontextactions-0.0.6.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for djangocontextactions-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ee8b6ce2a1c8271b651bc512cf267777822d1a1f0c70ece3ac896865ddb74d63
MD5 9b63771621d3b737871b2d2347c27a6b
BLAKE2b-256 748c322ee1f61fd2cfcda23adb6e4fd14801a461cf4c849f0435d24cd60e2b7f

See more details on using hashes here.

File details

Details for the file djangocontextactions-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for djangocontextactions-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0cd61bd3e715751c06d28973dcc91f1a327b383089aea1cf2a2f98bab408ab8a
MD5 7b6eeaa8d99351be77d13038684f516c
BLAKE2b-256 7b21005d917ef3fb9f69a38803c54fd9f6877bae03c7f1b38b2b02dbf6052c93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page