Django Migration Error: Column does not exist

后端 未结 15 2225
北恋
北恋 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:14

    Late to the party, but there is some info I want to share. It helped me a lot! :)

    I am using django-solo to store app config in database, and I got the same issue as Alex when adding new field to configuration model. Stacktrace pointed me to the line where I'm getting config from database: conf = SiteConfiguration().get_solo().

    There is a closed issue for django-solo project on Github. The idea is to make model loading lazy (exactly as MrKickkiller pointed before).

    So for modern Django version (in my case 3.0) this code works perfectly:

    from django.utils.functional import SimpleLazyObject
    conf = SimpleLazyObject(SiteConfiguration.get_solo)
    

提交回复
热议问题