Django migrations : relation already exists

前端 未结 6 936
南笙
南笙 2021-02-06 18:46

I have trouble with django model migrations. I have some models in my app, and I already have some data inside. When I added some models in my application, and I run mak

6条回答
  •  广开言路
    2021-02-06 19:16

    every time you make changes to your models, try these steps :

    python manage.py makemigrations [your app name]
    

    then:

    python manage.py migrate
    

    it should work fine. but remember if you have already data(rows) in your tables you should specify the default value for each one the queries.
    if not, Django prompt you to specify the default value for them or you can just try to use blank=True or null=True in your fields like below :

    website         = models.URLField(blank=True)
    

提交回复
热议问题