here is my models.py
file
from django.db import models
class Question(models.Model):
question_text = models.CharField("question",max_length=200)
pub_date = models.DateTimeField('date published')
#def __str__(self):
#return self.question_text
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
Here are the screenshots of errors
Please help me to rectify this problem.
Looking at your screenshot it seems, you did select 2nd option but never really added the default value here.
It seems you already had Choice
model and then later you added choice_text
field. The database need to add this column in the choice table so either you provide a default
value or you choose to go with null=True
Add a default value to choice_field
in Choice
model:
choice_text = models.CharField(max_length=200, default='your default value')
Or,
choice_text = models.CharField(max_length=200, null=True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.