Ask Your Question
3

Why does a TemplateDoesNotExist error occur on the Django app on Heroku even though it was successfully deployed locally?

asked 2021-11-12 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-01-22 05:00:00 +0000

plato gravatar image

There are several reasons why a TemplateDoesNotExist error may occur on a Django app deployed on Heroku even though it was successfully deployed locally.

  1. File paths: Heroku may have slightly different paths for the templates and static files compared to your local machine. Make sure that the file paths in your code match the paths on the Heroku server.

  2. Case sensitivity: Heroku servers may be case-sensitive when it comes to file names and paths. Double-check that your file and directory names are spelled correctly and match the case in your code.

  3. Gitignore: If you have added templates or static files to your .gitignore file, they will not be included when you deploy your app to Heroku. Ensure that your static files and templates are not being ignored in your .gitignore file.

  4. Collectstatic: By default, Heroku does not automatically run the collectstatic command when deploying a Django app. Make sure you have run python manage.py collectstatic locally and have included the resulting static files in your Git repository.

  5. Add-ons: If you are using add-ons such as Heroku Postgres or Heroku Redis, make sure they are configured correctly and are running without issues.

Overall, it's important to thoroughly test your app on the Heroku server and debug any errors that come up.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-12 11:00:00 +0000

Seen: 7 times

Last updated: Jan 22 '23