Django Migration Error: Column does not exist

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

    I got the same issue, here is my case: in the app MyApp I add a new field to the model:

    class Advisors(models.Model):
        AdvID = models.IntegerField(primary_key=True)
        Name = models.CharField(max_length=200,null=False)
        ParentID = models.IntegerField(null=True) # <--- the NEW field I add
    

    so what I did is: in the urls.py of MyProject, NOT MyApp, comment out the url() linked to MyApp and then do makemigrations and migrate everything goes well; in MyApp/urls.py file:

    urlpatterns = [
        url(r'^admin/', admin.site.urls, name='admin'),
        url(r'^$', views.HomePage.as_view(),name='home'),
        #comment out the following line, after migrate success, bring it back;
        # url(r'^myapp/', include('myapp.urls',namespace='research')), <--- 
    ]
    

提交回复
热议问题