Error when I try to add a new thing


#1

Hello,

First of all, thanks for this great course. I can’t imagine how much effort it takes to create something like this and I’m grateful for that.

That being said, I’m kinda stuck and could use some help.

I’m at the end of Chapter 6 and at the stage where I’ve just created the SQLite DB and tried to add my first Thing. However, I cannot seem to Save any entries as I keep hitting an error on clicking Save: OperationalError at /admin/collection/thing/add/

The code is exactly how you have it in Git. I did some Google searches and it seems to be a known issue in the Django community due to a new version of SQLite. I’m using the version of Django that the course recommends i.e. 2.0.9.

I’ve attached a screenshot of the full error message.

Can you please help me understand what’s going wrong here?

Thank you!


#2

Hi there! Just to confirm — you’ve run python manage.py makemigrations and python manage.py migrate after database changes, right? If so, what do they say if you run them again?


#3

Hi Tracy,
Yep, I did and it says No migrations.

PFA a screenshot showing what I got.

Thanks


#4

Sounds like this is related to the SQLite error: https://stackoverflow.com/questions/53637182/django-no-such-table-main-auth-user-old

Looks like Django updated the version of Django 2.0 to 2.0.10 to fix the bug. I updated my instructions.

Do you have any data in your database you need to save? Sounds like the best course of action would be to nuke the database, update Django, and then remake the database. Let me know if that sounds good on your end and I can write instructions. :)


#5

Hi Tracy,
I don’t have any data in my database, so that sounds good :)
Instructions would be great!


#6

Sorry for the delay, life has been crazy!

Instructions:

  • Turn off your local server (if it isn’t off already)
  • Delete your database file (.sqlite3 file)
  • Update Django to 2.0.10 (pip install Django=2.0.10)
  • Migrate database to get a new database file (python manage.py migrate)
  • Make a new superuser (python manage.py createsuperuser)
  • Migrate the new database just for extra funsies (python manage.py makemigrations then python manage.py migrate) — probably won’t have anything but I like double checking.

This is off of memory so I hope I didn’t miss anything! Let me know if you see anything weird.