1.把根目錄下的dev.db進行備份
python manage.py dumpdata > whole.json --settings=investblog.settings_local
2.把dev.db刪除 如果有問題, 將每個app內的migrations與_pycache_的file刪除, 但有_init_的不要刪除.
當初就是不知道這邊的setting會覆蓋掉, setting中的, 所以搞了很久.
5.migrate
python manage.py makemigrations
python manage.py migrate
註:實驗過程中用到的特別Django語法
```
# 假的migrate
python manage.py migrate --fake
# 查詢migrate歷史
python manage.py showmigrations
# 同步db
manage.py migrate --run-syncdb
# 進入shell, 可以debug
python manage.py shell
=>
import django
#查詢db connect是否正常 : No代表正常
print(django.db.connection.ensure_connection())
```
參考來源: https://stackoverflow.com/questions/43156053/mezzanine-django-1-10-migrations-database-tables-does-not-much-with-migrations https://stackoverflow.com/questions/52673215/start-mezzanine-project-with-custom-database https://stackoverflow.com/questions/59163167/django-postgresql-existing-database-does-not-exist https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html https://stackoverflow.com/questions/29253399/how-to-reset-migrations-in-django-1-7 https://medium.com/djangotube/django-sqlite-to-postgresql-database-migration-e3c1f76711e1 https://stackoverflow.com/questions/32098797/how-can-i-check-database-connection-to-mysql-in-django
SQL Server Analytics Service 1
SEO(1) Github(2) Title Tag(2) ML(1) 李宏毅(1) SQL Server(18) Tempdb(1) SSMS(1) Windows(1) 自我成長(2) Excel(1) python Flask(1) python(5) Flask(2)
Max Chen (159)