Skip to content
Advertisement

When typing: print(Topic.objects.all()) , I get the error message: django.db.utils.OperationalError: no such table:

hello after running this code in a models.py file:

JavaScript

As a note, I was having trouble with migrations as I kept getting error messages related to the .ForeignKey so I got the following code from some other forum, and it finally ran the migrations but I’m not sure if this code is the problem…

JavaScript

After successful migrations, I ran

JavaScript

everything seemed to migrate fine. Then I ran

JavaScript

then I ran:

JavaScript

but got the following error:

JavaScript

here’s the full read out:

JavaScript

models.py is in:

JavaScript

any help would be greatly appreciated, I’ve read a bunch of other threads on this topic and some say to toss the db.sqlite3 and pycache – is this what I should do?

thnx

Advertisement

Answer

I believe that I fixed the problem by doing the following steps below:

JavaScript

I believe that b4 I didn’t make the migrations apply to my first_app (the 2nd step) and then run the migration again(the 3rd step). Also I reinstalled django, this time with the pip installer and it seems to be working much better- as I was getting error messages b4. Right after I would install django in the app folder I was working in, it would say that it it can’t find django. This happened off and on. B4 I installed django with the command:

JavaScript

but have been having problems with conda, I have to always paste:

PATH=/Users/aleong/opt/anaconda3/bin:$PATH

b4 I create a virtual env with:

JavaScript

Also fixing the code in my models.py file as suggested by Somto (thnx Somto) helped, I replaced my code with:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement