Mezzanine/Django 1.10 migrations: Database tables

2019-09-19 19:45发布

问题:

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.