OperationalError, no such column. Django

后端 未结 22 1818
情话喂你
情话喂你 2020-12-24 00:45

I am very new to django and was able to finish the tutorial on djangoproject.com without any errors. I am now going through the Django REST framework tutorial found at http:

22条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 01:18

    Initially ,I have commented my new fields which is causing those errors, and run python manage.py makemigrations and then python manage.py migrate to actually delete those new fields.

    class FootballScore(models.Model):
        team = models.ForeignKey(Team, related_name='teams_football', on_delete=models.CASCADE)
        # match_played = models.IntegerField(default='0')
        # lose = models.IntegerField(default='0')
        win = models.IntegerField(default='0')
        # points = models.IntegerField(default='0')
    
    class FootballScore(models.Model):
        team = models.ForeignKey(Team, related_name='teams_football', on_delete=models.CASCADE)
        match_played = models.IntegerField(default='0')
        lose = models.IntegerField(default='0')
        win = models.IntegerField(default='0')
        points = models.IntegerField(default='0')
    

    Then i freshly uncommented them and run python manage.py makemigrations and python manage.py migrate and boom. It worked for me. :)

提交回复
热议问题