Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Django Lifecycle Hooks

[![Package version](https://badge.fury.io/py/django-lifecycle.svg)](https://pypi.python.org/pypi/django-lifecycle)
[![Python versions](https://img.shields.io/pypi/status/django-lifecycle.svg)](https://img.shields.io/pypi/status/django-lifecycle.svg/)
[![Package version](https://badge.fury.io/py/django-lifecycle.svg)](https://pypi.org/project/django-lifecycle/)
[![PyPI status](https://img.shields.io/pypi/status/django-lifecycle.svg)](https://pypi.org/project/django-lifecycle/)
[![Python versions](https://img.shields.io/pypi/pyversions/django-lifecycle.svg)](https://pypi.org/project/django-lifecycle/)
![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-lifecycle)
[![Django versions](https://img.shields.io/pypi/djversions/django-lifecycle)](https://pypi.org/project/django-lifecycle/)

This project provides a `@hook` decorator as well as a base model and mixin to add lifecycle hooks to your Django models. Django's built-in approach to offering lifecycle hooks is [Signals](https://docs.djangoproject.com/en/dev/topics/signals/). However, my team often finds that Signals introduce unnecessary indirection and are at odds with Django's "fat models" approach.

Expand Down
12 changes: 5 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Django Lifecycle Hooks

[![Package version](https://badge.fury.io/py/django-lifecycle.svg)](https://pypi.python.org/pypi/django-lifecycle)
[![Python versions](https://img.shields.io/pypi/status/django-lifecycle.svg)](https://img.shields.io/pypi/status/django-lifecycle.svg/)
[![PyPI status](https://img.shields.io/pypi/status/django-lifecycle.svg)](https://pypi.org/project/django-lifecycle/)
[![Python versions](https://img.shields.io/pypi/pyversions/django-lifecycle.svg)](https://pypi.org/project/django-lifecycle/)
![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-lifecycle)

[![Django versions](https://img.shields.io/pypi/djversions/django-lifecycle)](https://pypi.org/project/django-lifecycle/)

This project provides a `@hook` decorator as well as a base model and mixin to add lifecycle hooks to your Django models. Django's built-in approach to offering lifecycle hooks is [Signals](https://docs.djangoproject.com/en/dev/topics/signals/). However, my team often finds that Signals introduce unnecessary indirection and are at odds with Django's "fat models" approach.

Expand Down Expand Up @@ -50,7 +48,7 @@ Instead of overriding `save` and `__init__` in a clunky way that hurts readabili


def save(self, *args, **kwargs):
if self.pk is not None and self.contents != self._orig_contents):
if self.pk is not None and self.contents != self._orig_contents:
self.updated_at = timezone.now()

super().save(*args, **kwargs)
Expand All @@ -61,8 +59,8 @@ Instead of overriding `save` and `__init__` in a clunky way that hurts readabili

## Requirements

* Python (3.7+)
* Django (2.2+)
* Python (3.8+)
* Django (4.2+)

## Installation

Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ def readme():
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.2",
"Framework :: Django :: 6.0",
]
setup(
name="django-lifecycle",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist =
{py38,py39,py310,py311,py312}-django42
{py310,py311,py312}-django50
{py310,py311,py312,py313,py314}-django52
{py312,py314,py313,py314}-django60
{py312,py313,py314}-django60
flake8
skip_missing_interpreters = False

Expand Down