TLDR, I’m trying to solve an issue of sqlite3 db not getting updated after adding a new filed to an existing model. Im using 2.2.24 version.
This is what I’ve done.
- I tried and added a new image field to an existing model:
image = models.ImageField(upload_to='dialogs/', blank=True, null=True)
- I tried to make migrations with changes with
python manage.py makemigrationswhich created a new .py file in migrations folder:
name='Dialog', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=256)), ('text', models.TextField(blank=True, max_length=1000, null=True)), ('slug', models.SlugField(blank=True, null=True)), ('image', models.ImageField(blank=True, null=True, upload_to='dialogs/')), ], ),
- I tried to migrate
python manage.py migrate, but I came accross an error
django.db.utils.OperationalError: no such column: website_dialog.image
I guess the column
website_dialog.image should be addedd automatically, right? It did work earlier like that.
I have tried:
- Removing the db.sqlite3 file cleaning the migrations folder of any .py files and trying to make a migration again, but then I was getting the error
django.db.utils.OperationalError: no such table: website_homepage. Where
homepageis my first model on the list.
- I tried to
flushthe db and then create super user again and make migrations but this was returning me a 500 error so I reverted changes.
- I also tried to add a
website_dialog.imagemanually, but even though the field appeared in the admin panel, image could be loaded, but then couldn’t be removed.
What could be the problem that after adding the image field to the model, and creating the migration it doesn’t get migrated to the database?
Thanks in advanced