Mezzanine/Django 1.10 migrations: Database tables does not much with migrations

≯℡__Kan透↙ 提交于 2019-12-12 03:45:12

问题


I am using Mezzanine (Django 1.10) so I can't see a "db.sqlite3"

I searched similar questions as mine and most of the solutions provided were not effective.

I created a new model and later decided to add a new field. I did "python manage.py makemigrations ", and when I looked at my migrations folder, it's there; the new field exists. Now, when I ran the app and looked into admin, it gave me error where it said "No such column exists". Therefore, I think, my database is not synced with the migrations I have.

This is what I did: 1. deleted everything in the migration folder and recreated the "init.py".

1.1 ran "python manage.py makemigrations <app_name>"

1.2 ran "python manage.py migrate <app_name>"

1.3 ran "python manage.py runserver"

I can actually just rename my model into a different name with the same fields, however, sometimes Django would give error such as "no such table exist". It would also be quiet tedious to do because if I rename my model, I have to rename it in every file where I have imported the model such as in admin.py, forms.py, views.py, etc.

I heard about South, but its not applicable to Django 1.10.

Please Help. Thank you!


回答1:


I just solved this problem. Since I am using Mezzanine then the name of the database is not the same. Look for the file dev.db which would be located at the same folder of your manage.py. Then, delete it. Then, run python manage.py makemigrations and python manage.py migrate again. Then (I hope) it would work.



来源:https://stackoverflow.com/questions/43156053/mezzanine-django-1-10-migrations-database-tables-does-not-much-with-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!