2023-10-24 12:28:42 -04:00
|
|
|
from django.db import models
|
|
|
|
|
2023-10-29 16:09:38 -04:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.db.models.signals import post_save
|
|
|
|
from django.dispatch import receiver
|
|
|
|
|
2023-10-24 12:28:42 -04:00
|
|
|
# Create your models here.
|
2023-11-11 18:03:08 -05:00
|
|
|
class ProfileModel(models.Model):
|
2023-10-29 16:09:38 -04:00
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
|
|
title = models.CharField(max_length=40)
|
|
|
|
|
|
|
|
@receiver(post_save, sender=User)
|
|
|
|
def on_user_created(sender, instance, created, **kwargs):
|
|
|
|
if created:
|
2023-11-11 18:03:08 -05:00
|
|
|
profile: ProfileModel = ProfileModel.objects.create(pk = instance.pk, user = instance)
|
2023-10-29 16:09:38 -04:00
|
|
|
profile.save()
|