Srijan Veer Shobhan Srijan Veer Shobhan - 6 months ago 7
SQL Question

I can't figure out why my makemigrations isn't working in django,its showing following error

here is my

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

Here is screenshot of my cmd

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')


choice_text = models.CharField(max_length=200, null=True)