from django.conf import settings
from django.db import models
from django.db.models.signals import post_save,pre_save

User = settings.AUTH_USER_MODEL

class Profile(models.Model):
    user = models.OneToOneField(User,on_delete = models.CASCADE)
    location = models.CharField(max_length = 220 , null = True, blank = True)
    bio = models.TextField(blank = True,null = True)
    
    
def user_did_save(sender , instance , created , *args, **kwargs):
    if created:
        Profile.objects.get_or_create(user = instance)
    
post_save.connect(user_did_save,sender = User)