这是我一直在做的事情,我想这不是正确的解决方案:
db.sqlite3
文件 makemigrations
然后 migrate
如果我 不 删除
db.sqlite3
文件,当我尝试运行 makemigrations
然后 migrate
时,我有这个:manage.py@pyweb > makemigrations
"C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\bin\runnerw.exe" C:\Python34\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pycharm\django_manage.py" makemigrations C:/Users/Olivier/PycharmProjects/pyweb
No changes detected
Process finished with exit code 0
manage.py@pyweb > migrate
"C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\bin\runnerw.exe" C:\Python34\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pycharm\django_manage.py" migrate C:/Users/Olivier/PycharmProjects/pyweb
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages, produits
Apply all migrations: sessions, auth, contenttypes, admin
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
Process finished with exit code 0
为了避免删除 db 文件,我错过了什么步骤?
最佳答案
更改模型后,您只需执行
python manage.py makemigrations your_app
然后迁移它
python manage.py migrate
这样做您不必删除您的数据库。
我希望这对您有所帮助.. 但是不要忘记在对模型应用更改后运行 makemigrations