[Django]-Django – create new Objects when new user is registered

6👍

You can use signals for this so that every time a new user is created, new objects for Tipp are also created, e.g.:

from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Tipp

@receiver(post_save, sender=User)
def create_user_picks(sender, instance, created, **kwargs):
    if created:
        Tipp.objects.create(user=instance)
👤MeL

Leave a comment