Skip to content

Commit

Permalink
Feat: 업데이트 레시피 자동 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
newbission committed Jun 20, 2024
1 parent 52fb354 commit 1911a4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/recipes/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class RecipesConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "recipes"

def ready(self):
import recipes.signals
8 changes: 8 additions & 0 deletions app/recipes/signals.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1911a4a

Please sign in to comment.