我正在尝试修复django.db.utils.IntegrityError:NOT NULL约束失败:new__exp_answer.user_id
from django.db import models
from django.contrib.auth.models import User
class Question(models.Model):
userquestion=models.CharField(max_length=30,null=True,blank=True)
def __str__(self):
return self.userquestion
@property
def question(self):
return self.answer_set.all()
@property
def votes(self):
return self.answer_set.count()
class Answer(models.Model)
key=models.ForeignKey('Question', on_delete=models.CASCADE,null=True)
kess=models.ManyToManyField('Question', related_name= 'userquestion1')
useranswer=models.CharField(max_length=30,null=True,blank=True)
image1=ImageField(upload_to='media/images',default="",null=True,blank=True)
def __str__(self):
return self.useranswer
class Relate(models.Model):
users=models.ForeignKey(User,on_delete=models.CASCADE,null=True)
kess1=models.ManyToManyField('Answer', related_name= ' userquestion12 ')
def __str__(self):
return self.users.first_name