我有以下型号:
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)
配置文件由以下信号创建:
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(name=instance)
当我添加新用户时,它不会创建新的配置文件,而当我尝试手动添加配置文件时,主键字段的值将为None
。
谁能告诉我出什么问题了?
谢谢