Django, ManyToManyField - ProgrammingError: relation foo_bar does not exist. Recognized in migrations, though relation is never created

后端 未结 1 1465
-上瘾入骨i
-上瘾入骨i 2020-12-21 19:33

In this case, \"foo_bar\" is actually \"links_userprofile_favorite_feeds\".

The problem is, when I go into manage.py shell:

manage.py shell



        
相关标签:
1条回答
  • 2020-12-21 20:26

    Fixed.

    For those with this problem in the future:

    1. Delete all links_* tables from the database (app was called 'links')
    2. Delete all migrations for the 'links' app by doing:

      from django.db.migrations.recorder import MigrationRecorder
      MigrationRecorder.Migration.objects.filter(app='links').delete()
      
    3. Migrated forward with manage.py migrate

    0 讨论(0)
提交回复
热议问题