0

I'm reading this awesome Django 4.0 for Beginners book by William S. Vincent https://djangoforbeginners.com/.

Chapter 4 builds a simple Message Board App and deploys to Heroku.

Running the app locally works with no problems. A simple webpage is returned. And all the tests are completed with no problems also.

enter image description here

Pushing the code to Heroku is straightforward, and no errors are encountered.

But once the code is live at Heroku, it doesn't like what ran on my localserver with no problems.

Heroku error message:

no such table: posts_post
<!-- templates/home.html -->
<h1>Message board homepage</h1>
<ul>
  {% for post in post_list %}
    <li>{{ post.text }}</li>
  {% endfor %}
</ul>

I'm not quite sure what this error is trying to tell me. The code looks fine, so the issue must be elsewhere. And I don't understand how Django can run locally with no issues, but then Heroku doesn't like it.

Initially I thought that the Python Black "Format on Save" was messing with the HTML indentation (4 characters vs 2 characters). I disabled Black's Format on Save and set indentation to 2 characters in the templates/home.html file. This also worked locally, but ended in the same error at Heroku.

I followed all the steps in the book regarding deployment.

  1. install Gunicorn
  2. create requirements.txt file
  3. update ALLOWED_HOSTS
  4. create Procfile
  5. create runtime.txt file

Any ideas where I need to look in the Django project to solve this? And why would Heroku not like code that works locally?

enter image description here

jarthoben
  • 129
  • 1
  • 11

0 Answers0