Django Migration Error: Column does not exist

后端 未结 15 2303
北恋
北恋 2020-12-10 10:25

Python 3, Django 1.8.5, Postgres

I have a model Sites that has been working fine. I recently tried to add a field, airport_code, and migrate the data.

15条回答
  •  隐瞒了意图╮
    2020-12-10 11:06

    Make sure you are not doing any queries when loading the application!, as eg. in:

    class A:
      field = fn_that_makes_query()
    

    When running migrate or makemigrations, Django performs system checks, which loads the entire application, so if during this process any queries are made which use added/altered db fields you run into inconsitencies, because you are trying to access db fileds that are not there yet.

提交回复
热议问题