From 72d8972501795ba652267a7b1f804724664ecd2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 4 Nov 2022 11:22:14 +0000 Subject: [PATCH] Synced README changes to docs --- docs/README.md | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/docs/README.md b/docs/README.md index 4a63c9ed..88c2c0a9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -38,6 +38,8 @@ This solves the problem introduced by using `instance.pk = None` and `instance.s * [List View](#list-view) * [Change View](#change-view) * [CloneModelAdmin class attributes](#clonemodeladmin-class-attributes) + * [Signals](#signals) + * [pre\_clone\_save, post\_clone\_save](#pre_clone_save-post_clone_save) * [Compatibility](#compatibility) * [Running locally](#running-locally) * [Found a Bug?](#found-a-bug) @@ -340,6 +342,31 @@ INSTALLED_APPS = [ ] ``` +### Signals + +#### pre\_clone\_save, post\_clone\_save + +```python +from django.dispatch import receiver +from django.utils import timezone + +from model_clone.signals import post_clone_save, pre_clone_save + +from sample.models import Edition + + +@receiver(pre_clone_save, sender=Edition) +def increase_seq(sender, instance, **kwargs): + instance.seq += 1 + + +@receiver(post_clone_save, sender=Edition) +def update_book_published_at(sender, instance, **kwargs): + if instance.book: + instance.book.published_at = timezone.now() + instance.book.save(update_fields=["published_at"]) +``` + ## Compatibility | Python | Supported version | @@ -393,16 +420,16 @@ Thanks goes to these wonderful people: - - - - - - - + + + + + + + - +

Gerben Neven

πŸ› ⚠️ πŸ’»

Sebastian Kapunkt

πŸ’» πŸ› ⚠️

AndrΓ©s Portillo

πŸ›

WhiteSource Renovate

🚧

Yuekui

πŸ’» πŸ› ⚠️

Take Weiland

⚠️ πŸ› πŸ’»

Patrick

πŸ› πŸ’»
Gerben Neven
Gerben Neven

πŸ› ⚠️ πŸ’»
Sebastian Kapunkt
Sebastian Kapunkt

πŸ’» πŸ› ⚠️
AndrΓ©s Portillo
AndrΓ©s Portillo

πŸ›
WhiteSource Renovate
WhiteSource Renovate

🚧
Yuekui
Yuekui

πŸ’» πŸ› ⚠️ πŸ“–
Take Weiland
Take Weiland

⚠️ πŸ› πŸ’»
Patrick
Patrick

πŸ› πŸ’»

Amiel Kollek

πŸ’» πŸ› ⚠️
Amiel Kollek
Amiel Kollek

πŸ’» πŸ› ⚠️