0

I have the below models:

class Profile(models.Model):
    date = models.DateTimeField(auto_now_add=True)
    full_name = models.CharField(max_length=32,blank=True)
    name = models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
    e_mail = models.EmailField(max_length=70,blank=True)
    permanant_address = models.TextField(blank=True)
    subscribed_products = models.ManyToManyField(Product,related_name='products_subscribed',blank=True)

The profile is created by the below signal:

@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(name=instance)

When I add a new user it doesnot creates a new profile and when I try to add profile manually the value of the primary key field is coming None..

Can anyone tell me what is wrong?

Thank you

Niladry Kar
  • 1,163
  • 4
  • 20
  • 50

0 Answers0