0

I'm setting up my new website, but the web have some problem. It gives me an OperationalError at /topics/ and no such table: toms_topic.

This is a Heroku web dyno, running Django2.2 and Python 3.7.3.

I have executed

python manage.py migrate

and when I go to the db.sqlite I find the table toms_topic exists.

And everybody can goto the website https://cblingh.herokuapp.com for take more information

My last website haven't this problem,maybe I add image this time,and the image is foreignkey with topic.But i not sure it's the key of this problem yet.The topic have two foreignkey (entry,image).

  • have you run makemigrations? – thirteen4054 Apr 08 '19 at 00:48
  • sure,I have run makemigrations and migrate,and the toms_topic have exist in my db.sqlite – binghuang cai Apr 08 '19 at 00:54
  • @binghuangcai, I don't know anything about your last website but I can promise you, if you're hosting on Heroku and writing data to an SQLite database you're not getting the result you think you are. You _must_ use a client-server database instead of a file-based one on Heroku. That's the nature of its filesystem. – ChrisGPT was on strike Apr 08 '19 at 01:58

1 Answers1

3

You can't use SQLite on Heroku. Its filesystem is dyno-local and ephemeral. Any changes you make to it will be lost whenever your dyno restarts. This happens frequently (at least once per day).

Heroku offers good support for client-server databases. If you want to use Heroku you'll have to switch to one. Their own PostgreSQL service works well and is available out of the box. If you prefer other databases feel free to browse the data store addons.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257