Search code examples
djangodatabase-migration

problem: Table doesn't exist( python manage.py migrate)


I dropped some table related to an app. and again tried the syncdb command

python manage.py migrate

It shows error like

django.db.utils.ProgrammingError: (1146, "Table 'someapp.feed' doesn't exist")

models.py

class Enroll_course(models.Model):
    SHFE_CHOICES = (
        ('M', 'Moring'),
        ('E', 'Evening'),
    )
    BATCH_CHOICES = (
        ("A", "1ST"),
        ("B", "2ND")
    )
    userinfo = models.ForeignKey(User, on_delete=models.CASCADE)
    course = models.ForeignKey(Course, on_delete=models.CASCADE)
    batch = models.CharField(max_length=1, choices=BATCH_CHOICES, default="A")
    shife = models.CharField(max_length=1, choices=SHFE_CHOICES, default="M")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

Solution

  • I think what happend is that you lost sync with the migration and the db.

    Try to delete all the migration related to this table.

    (If nothing improtant you can delete all migrations files in the specific app).

    Then run python manage.py makemigrations - to create all the migrations again.

    Then run python manage.py migrate