程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Some errors encountered by Django in deleting tables

編輯:Python
python manage.py sqlmigrate DouYin 0001

Funny Django, After deleting from the database , The database cannot be created again successfully . For a long time , Finally found a way . Delete the code you don't need and Server side database , Then, the local system still executes once

python manage.py makemigrations
python manage.py migrate

, Then use this command :
python manage.py sqlmigrate 【 Yours Modle name 】 0001

You can see one Sql sentence , Just execute this statement on the server , It is equivalent to creating a new data table on the server side , And then use Django The data in the table of is normal , You can normally delete and add operations .
If you encounter New fields always report errors , You can add... To the new field The default value is , And then the execution is Ok 了 .

Only one of the auto growth and primary key is effective


The above method doesn't work !
The specific solution is :

After deletion, it cannot be created successfully again ,what?

python manage.py makemigrations app

app Means your Module


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved