{"id":14972703,"url":"https://github.com/salaah01/django-action-triggers","last_synced_at":"2025-04-06T06:07:09.769Z","repository":{"id":254008049,"uuid":"841038471","full_name":"Salaah01/django-action-triggers","owner":"Salaah01","description":"A Django library for asynchronously triggering actions in response to database changes. It supports integration with webhooks, message brokers (e.g., Kafka, RabbitMQ), and can trigger other processes, including AWS Lambda functions.","archived":false,"fork":false,"pushed_at":"2025-03-18T03:42:55.000Z","size":3732,"stargazers_count":66,"open_issues_count":21,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T06:07:00.325Z","etag":null,"topics":["asyncio","automation","database-events","django","django-application","django-rest-framework","event-driven","events","extensible","kafka","message-broker","message-queue","python","queue","rabbitmq","triggers","webhooks"],"latest_commit_sha":null,"homepage":"https://django-action-triggers.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Salaah01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-08-11T13:08:35.000Z","updated_at":"2025-03-27T14:52:12.000Z","dependencies_parsed_at":"2024-09-14T13:40:42.841Z","dependency_job_id":"89d5d222-f530-4ccb-a8e2-db65a87a7e18","html_url":"https://github.com/Salaah01/django-action-triggers","commit_stats":{"total_commits":89,"total_committers":3,"mean_commits":"29.666666666666668","dds":0.4831460674157303,"last_synced_commit":"b5cb7572fa2fbcaeb6ccc1a35131e21f5e21fceb"},"previous_names":["salaah01/django-action-triggers"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salaah01%2Fdjango-action-triggers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salaah01%2Fdjango-action-triggers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salaah01%2Fdjango-action-triggers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salaah01%2Fdjango-action-triggers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Salaah01","download_url":"https://codeload.github.com/Salaah01/django-action-triggers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441046,"owners_count":20939239,"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":["asyncio","automation","database-events","django","django-application","django-rest-framework","event-driven","events","extensible","kafka","message-broker","message-queue","python","queue","rabbitmq","triggers","webhooks"],"created_at":"2024-09-24T13:47:23.750Z","updated_at":"2025-04-06T06:07:09.745Z","avatar_url":"https://github.com/Salaah01.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Django Action Triggers\n\n![License: MIT](https://img.shields.io/badge/license-MIT-blue) [![PyPI version](https://badge.fury.io/py/django-action-triggers.svg)](https://badge.fury.io/py/django-action-triggers) [![codecov](https://codecov.io/github/Salaah01/django-action-triggers/graph/badge.svg?token=ROHNEE9D4X)](https://codecov.io/github/Salaah01/django-action-triggers) ![PyPI - Supported Python Versions](https://img.shields.io/pypi/pyversions/django-action-triggers) ![Supported Django Versions](https://img.shields.io/badge/django-3.2%20%7C%204.2%20%7C%205.1-blue)\n\n\n## Table of Contents\n- [Django Action Triggers](#django-action-triggers)\n  - [Table of Contents](#table-of-contents)\n  - [Description](#description)\n  - [Why Use Django Action Triggers Over Django Signals?](#why-use-django-action-triggers-over-django-signals)\n    - [How Django Action Triggers Helps](#how-django-action-triggers-helps)\n    - [Built-in Integrations](#built-in-integrations)\n    - [Key Benefits:](#key-benefits)\n  - [Key Features](#key-features)\n  - [Documentation](#documentation)\n  - [Supported Message Brokers](#supported-message-brokers)\n  - [Supported Actions](#supported-actions)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [Example Scenarios](#example-scenarios)\n    - [Example 1: Webhook Trigger on User Creation/Update/Deletion](#example-1-webhook-trigger-on-user-creationupdatedeletion)\n    - [Example 2: Webhooks and Message Queues on Product and Sale Creation/Update](#example-2-webhooks-and-message-queues-on-product-and-sale-creationupdate)\n  - [Don't See What You're Looking For?](#dont-see-what-youre-looking-for)\n  - [License](#license)\n\n\n## Description\n\n![Django Action Triggers Animation](./docs/source/_static/img/django-action-triggers-animation-dark.gif)\n\nIn Django, signals are a powerful tool for responding to changes in your models or other parts of the application. Typically, you define signals in a signals.py file, specifying actions to take when certain events occur, like saving or deleting an object. While this approach works well in many cases, it can have some limitations:\n\nThis application is highly flexible and can be configured via code or through the Django admin interface.\n\n## Why Use Django Action Triggers Over Django Signals?\n\nIn Django, signals are typically hardcoded in a `signals.py` file, where you define logic like \"if this happens, do that.\" While this works well for many cases, it introduces a few limitations:\n\n- **Changes require code updates:** Adding or modifying signals requires changes to your codebase and redeployment.\n- **Static and inflexible:** Anytime you need to modify, add, or remove signals, you have to manually edit the code and redeploy the application.\n- **Maintenance overhead:** As your application grows, managing signals this way can make the code harder to maintain and scale.\n\n### How Django Action Triggers Helps\n\nDjango Action Triggers builds on Django’s signals by offering more flexibility at runtime. It allows you to create, modify, or remove signals and actions dynamically—**without needing to change your code**. This can all be done through the **UI or API**, making it easier to manage triggers and actions as your application evolves.\n\nWith Django Action Triggers, you can:\n\n- **Manage signals dynamically** without redeployment, using the admin interface or API.\n- **Adjust workflows at runtime** to respond to new requirements or integrations.\n- **Reduce the need for manual code changes** when setting up new signals or actions.\n\n### Built-in Integrations\n\nDjango Action Triggers also includes **out-of-the-box support** for popular services such as **AWS SNS**, **RabbitMQ**, **Kafka**, and more. This allows you to easily send messages to these services, streamlining integrations without needing custom code.\n\n### Key Benefits:\n\n- **No code changes or redeploys needed:** Manage signals and actions entirely through the UI or API.\n- **Flexibility at runtime:** Easily add, modify, or remove actions and triggers on the fly.\n- **Built-in integrations:** Connect seamlessly with external services like AWS SNS, Kafka, Redis, and more, saving time on implementation.\n\nIn summary, Django Action Triggers provides a **dynamic**, **maintainable** and **scalable** way to manage actions triggered by signals. It reduces the need for constant code changes while offering simple integration with popular external services.\n\n## Key Features\n\n- **Database-Driven Triggers**: Automatically trigger actions based on model events (e.g., save, delete).\n- **Webhook Integration**: Send HTTP requests to external services when triggers are activated.\n- **Message Broker Integration**: Send messages to messaging brokers like Kafka and RabbitMQ.\n- **Actions Integration**: Trigger actions like AWS Lambda functions based on model events.\n- **Extensible**: Easily extend to support custom triggers and actions.\n- **Secure Dynamic Configuration**: Dynamically set values at runtime for secure and flexible configuration.\n\n## Documentation\n\nFor detailed documentation, including setup, configuration options, API specifications, and more examples, please refer to the [official documentation](https://django-action-triggers.readthedocs.io/en/latest/).\n\n## Supported Message Brokers\n\n* Kafka\n* RabbitMQ\n* Redis\n* AWS SQS (Amazon Simple Queue Service)\n* AWS SNS (Amazon Simple Notification Service)\n* GCP Pub/Sub (Google Cloud Pub/Sub)\n\n## Supported Actions\n\n* AWS Lambda\n\nNeed support for another message broker or action? Please submit a feature request on the [GitHub repository](https://github.com/Salaah01/django-action-triggers/issues).\n\n## Installation\n\nTo install the package, run the following command:\n\n```bash\npip install django-action-triggers\n```\n\nThis command above will only install the base library, in order to support\nspecific integrations, you can install the following extras:\n\n| Integration | Installation Command                           |\n| ----------- | ---------------------------------------------- |\n| RabbitMQ    | `pip install django-action-triggers[rabbitmq]` |\n| Kafka       | `pip install django-action-triggers[kafka]`    |\n| Redis       | `pip install django-action-triggers[redis]`    |\n| AWS SQS     | `pip install django-action-triggers[aws]`      |\n| AWS SNS     | `pip install django-action-triggers[aws]`      |\n| GCP Pub/Sub | `pip install django-action-triggers[gcp]`      |\n| AWS Lambda  | `pip install django-action-triggers[aws]`      |\n| Webhooks    | `pip install django-action-triggers[webhooks]` |\n\nThen, add the following to your `INSTALLED_APPS` in your Django settings:\n\n```python\nINSTALLED_APPS = [\n    ...\n    'action_triggers',\n    ...\n]\n```\n\nIf you plan on using the API, add the following to your `urls.py`:\n\n```python\nfrom django.urls import path, include\n\nurlpatterns = [\n    ...\n    path('api/action-triggers/', include('action_triggers.urls')),\n    ...\n]\n```\n\n## Usage\n\nOnce installed, you can create triggers and actions using the Django admin interface or programmatically through the API.\n\nFor detailed usage instructions, configuration options, and examples, please refer to the [official documentation](https://django-action-triggers.readthedocs.io/en/latest/).\n\n## Example Scenarios\n\n### Example 1: Webhook Trigger on User Creation/Update/Deletion\n\nTrigger a webhook whenever a `User` model is created, updated, or deleted:\n\n```json\n{\n  \"config_signals\": [\n    {\"signal\": \"post_save\"},\n    {\"signal\": \"post_delete\"}\n  ],\n  \"content_types\": [\n    {\n      \"app_label\": \"auth\",\n      \"model_name\": \"User\"\n    }\n  ],\n  \"webhooks\": [\n    {\n      \"url\": \"https://my-webhook.com\",\n      \"http_method\": \"POST\",\n      \"headers\": {\n        \"Authorization\": \"Bearer {{ myapp.utils.get_token }}\"\n      },\n      \"timeout_secs\": 22.5\n    }\n  ],\n  \"active\": true\n}\n\n```\n\n### Example 2: Webhooks and Message Queues on Product and Sale Creation/Update\n\nTrigger multiple webhooks and add messages to queues when `Product` or `Sale` models are created or updated:\n\n```json\n{\n  \"config_signals\": [\n    {\"signal\": \"post_save\"}\n  ],\n  \"content_types\": [\n    {\n      \"app_label\": \"myapp\",\n      \"model_name\": \"Product\"\n    },\n    {\n      \"app_label\": \"myapp\",\n      \"model_name\": \"Sale\"\n    }\n  ],\n  \"webhooks\": [\n    {\n      \"url\": \"https://my-webhook.com\",\n      \"http_method\": \"POST\",\n      \"headers\": {\n        \"Authorization\": \"Bearer {{ myapp.utils.get_token }}\"\n      },\n      \"timeout_secs\": 10.5\n    },\n    {\n      \"url\": \"https://my-other-webhook.com\",\n      \"http_method\": \"POST\",\n      \"headers\": {\n        \"Authorization\": \"Bearer {{ myapp.utils.get_token }}\"\n      }\n    }\n  ],\n  \"msg_broker_queues\": [\n    {\n      \"name\": \"my-msg-broker-config\",\n      \"parameters\": {\n        \"product_id\": \"{{ myapp.utils.get_product_id }}\"\n      },\n      \"timeout_secs\": 2.5\n    },\n    {\n      \"name\": \"my-other-msg-broker-config\",\n      \"parameters\": {\n        \"sale_id\": \"{{ myapp.utils.get_sale_id }}\"\n      }\n    }\n  ],\n  \"active\": true\n}\n```\n\n## Don't See What You're Looking For?\n\nIf you have any feature requests or issues, please submit them to the [GitHub repository](https://github.com/Salaah01/django-action-triggers/issues). This also helps us prioritise new features and bug fixes.\n\n## License\n\nThis project is licensed under the MIT License - see [LICENSE](./LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalaah01%2Fdjango-action-triggers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalaah01%2Fdjango-action-triggers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalaah01%2Fdjango-action-triggers/lists"}