--- id: django-lifecycle version: "1.3.0" license: MIT license_treatment: permissive maintenance: active --- # django-lifecycle — Declarative model lifecycle hooks. License: permissive · Maintenance: active · Downloads: 257.8K/mo ## What it is and what it does Django Lifecycle Hooks provides a decorator-based alternative to Django Signals for attaching code to model lifecycle events. Instead of overriding save() or __init__ and manually tracking field changes, you decorate methods with @hook and specify when they should run (before/after create, update, or delete) and under what conditions. The package includes a LifecycleModel base class and condition helpers like WhenFieldHasChanged and WhenFieldValueIs to express complex logic declaratively. The main appeal is readability and maintainability: lifecycle logic stays close to the model definition rather than scattered across signal handlers. It works with Django 4.2, 5.0, 5.2, and 6.0, and supports Python 3.8 through 3.14. The package has been in active development since 2018 and carries no known security vulnerabilities. Use it for: - Automatically update a timestamp field whenever a model's content changes, without overriding save(). - Trigger side effects (like sending emails) only when a model transitions between specific states (e.g., draft to published). - Run validation or cleanup logic before or after a model is created, updated, or deleted, with fine-grained conditions. - Track field changes and react to them in the same model class, keeping related logic together and readable. - Replace Signal handlers for simple lifecycle events when you want less indirection and clearer code flow. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds declarative lifecycle hooks to Django models via a @hook decorator, letting you run code at specific model events (before/after create, update, delete) without overriding save() or using Signals. Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and solves a real readability problem in Django projects. It's a straightforward drop-in for teams that find Signals cumbersome and prefer declarative, co-located lifecycle logic. The MIT license imposes no restrictions. ## Install pip install django-lifecycle uv add django-lifecycle poetry add django-lifecycle ## Installing django-lifecycle Before you install: Low friction install with a single runtime dependency (Django). Active maintenance as of 2026-06-14 with 1405 repository stars and recent releases. License in practice: MIT license (permissive) — you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions. Quickstart: pip install django-lifecycle from django_lifecycle import LifecycleModel, hook, BEFORE_UPDATE from django_lifecycle.conditions import WhenFieldHasChanged class Article(LifecycleModel): contents = models.TextField() updated_at = models.DateTimeField(null=True) @hook(BEFORE_UPDATE, WhenFieldHasChanged("contents", has_changed=True)) def on_content_change(self): self.updated_at = timezone.now() Verify before relying: - Whether the package supports Python 3.14 as a stable release or only as a pre-release target - Whether Django 6.0 is currently released or a future version target ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 257.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django model lifecycle hooks, django before after save hooks, django model callbacks, django lifecycle decorator, django model event hooks, django conditional model hooks, django-models, lifecycle-hooks, orm-utilities [View on SkillFed](https://skillfed.io/packages/django-lifecycle) · [View on PyPI](https://pypi.org/project/django-lifecycle/)