From 1911a4a52761b2ea136a8fca059b7a96de608010 Mon Sep 17 00:00:00 2001 From: newbission Date: Thu, 20 Jun 2024 12:17:13 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=9E=90=EB=8F=99=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/recipes/apps.py | 3 +++ app/recipes/signals.py | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 app/recipes/signals.py diff --git a/app/recipes/apps.py b/app/recipes/apps.py index 683b24f..633e096 100644 --- a/app/recipes/apps.py +++ b/app/recipes/apps.py @@ -4,3 +4,6 @@ class RecipesConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" name = "recipes" + + def ready(self): + import recipes.signals diff --git a/app/recipes/signals.py b/app/recipes/signals.py new file mode 100644 index 0000000..e04b1ff --- /dev/null +++ b/app/recipes/signals.py @@ -0,0 +1,8 @@ +from django.db.models.signals import post_save +from django.dispatch import receiver +from .models import Recipe, Updated_recipe + +@receiver(post_save, sender=Recipe) +def create_updated_recipe_on_recipe(sender, instance, created, **kwargs): + if created: + Updated_recipe.objects.create(status='new', recipe=instance) \ No newline at end of file