Getting really strange error when deploying a django app on Heroku - django

I tried to deploy my django application to heroku using the starter guide and the other manual that shows you to create your runtime, requirements, procfiles, installing django-heroku, etc. So I've now deployed my site but recieve the following error.My error I'm unsure of why this error is showing up at all especially when it worked perfectly fine locally. I haven't followed all of the django deployment checklist yet, such as setting DEBUG to False because I'd like to ensure that it works correctly before I do. If anyone could help me, that'd be much appreceiated!

You have to do migration after pushing to Heroku.
Note: Don't use local migrations. You can use Heroku bash to connect remotely and perform migrations just like you do locally.

Related

How to launch an instance of my Flask app on Heroku

I am having a hard time deploying my little flask app to Heroku. I created it in visual studio community and just want to deploy it now to Heroku.
App code:
https://github.com/Phasor/QR-Site-2020
I signed up for a free account at Heroku and am following this guide: https://devcenter.heroku.com/articles/getting-started-with-python#deploy-the-app
I ran the following commands in their CLI:
git clone https://github.com/heroku/QR-Site-2020.git
heroku create
git push heroku master
When I write heroku ps:scale web=1 I get the following error:
Couldn't find that process type (web).
Looking for advice online it seems I need to define something called a Procfile. I have tried to do that and defined it as:
web: gunicorn runserver:app although I am very unsure that is correct (I normally just hit the "play" button in VS to run the app locally). Adding the Procfile does not solve the error message. I believe it should not hav the .txt extension but not sure you can create a text file without that in VS.
Originally I was not using gunicorn but think I may need to use that for Heroku so I added that to my requirements.txt.
Can anyone give me any pointers? Thanks

Django-Heroku Deployment Procfile

I've created a basic Django app and I wanted to deploy it with Heroku. I have followed all the instructions given on Heroku but there was one error I made which was naming the file "procfile" instead of "Procfile". Now the website has been deployed but it only opens up to an application error. Upon checking the log, I have found the error code to be H14. I have since renamed the "procfile" to "Procfile" but the change doesnt seem to be integrated. How do I fix this?
Add the change on your repository, commit it, and push the applicable branch to Heroku. Finally, try to run Heroku again.

Django CMS Deployment issues using Apphooks with Postgresql

I am trying to run a Django CMS project that i created recently. The project uses PostgreSQL for its database, and works great with the runserver command.
But i started having intermittent Bad Gateway(Nginx) issues when i deployed the project using NGINX and WSGI. This error was sometimes happening on the whole site or sometimes in the sidebar where the pages, administration, etc would show up or sometimes in the page or advanced page settings.
The error i was getting was as follows:
django.db.utils.OperationalError: SSL error: decryption failed or bad record mac
So i decided to get into the details of the error and found out that this error occurs only when i am using AppHooks in the project and that too only with PostgreSql. The project worked well when i deployed it using Sqlite database.
I further tried to resolve the issue by setting ssl = false in the config. file of PostgreSql to see if that would change anything. It changed the error i was getting earlier as follows:
django.db.utils.InterfaceError: connection already closed
So i was wondering the reason behind this issue? Let me remind you that this error is happening only when the project is deployed and not when runserver is being used.
UPDATE:
I tried using the Django-debug-toolbar to check what sql queries are being executed during these errors and it turns out the app is working fine. Somehow the debug toolbar is slowing down the applications which is not breaking the app any more. What might be the reason for the app to not work? How can i get around this issue

Heroku app with Django and postgres crashing unexpectdly

I am new to Django development, but I am in a situation where I need to deploy a large project on Heroku.
I ran my app in local system, it worked fine.
I pushed the same to Heroku and it also worked fine. But after few hours I open my app URL in browser , then app is saying Some thing has broken,intimated to admin.
The app worked fine before few hours, but what happened after few hours.
I just pushed my old DB backup to Heroku DB, Thats it app running fine now.
But I confused what happened to my app, I am facing this problem again and again,
how can I avoid this problem in future.
My app configuration:
psycopg2==2.4.5
Django==1.4
This could be a number of causes. It sounds more like a database issue. I would run the following command
heroku pg # TAKE NOTE OF THE HEROKU_POSTGRESQL_[COLOR]_URL
heroku pg:reset HEROKU_POSTGRESQL_[COLOR]_URL --confirm [appname]
This will reset your postgres database that is the active one, remove all tables etc.
Then I would run the regular command to get your database backup and running.
manage.py syncdb
You can also do the following
manage.py validate
This will go through your modules and tell you if any errors are present.
If that fails - enable debug in your settings.py file.
Also you can run "heroku logs" this will tell you the last few errors and statuses that have been hit with your app.
Let me know if this works, if not I will help debug further.

Deploying django project on AWS elastic beanstalk

I am following the tutorial for deploying a django project on AWS elastic beanstalk here:
http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
My app works when I test locally but when I deploy, I'm getting a 404 error. Looking at the event logs, I see this message:
Error running user's commands : An error occurred running '. /opt/python/ondeck/env && PYTHONPATH=/opt/python/ondeck/app: django-admin.py syncdb --noinput' (rc: 127) /bin/sh: django-admin.py: command not found
That leads me to believe that the tutorial is missing a part about installing django files on the server or at least configuring my project to recognize django-admin.py. I have django installed on my local machine so it works there.
I know python support is brand new for elastic beanstalk but has anyone deployed django to it?
I believe you don't need to put container_commands in .config because there is no database or table at this moment.
Did you made the step?: Freeze the requirements.txt file.
(djangodev)# pip freeze > requirements.txt
Note
Make sure your requirements.txt file contains the following:
Django==1.4.1
MySQL-python==1.2.3
I had the same problem because I skipped it. Once I did it, add, commit and push. It works!
I followed the same tutorial recently and had a similar result.
At step 6, upon seeing the default django 'congrats' page render locally, I deployed to EB as instructed and got a 404 instead of the default 'congrats' page.
I decided to use the code up to that point as a foundation for following the 'getting started with django tutorial' which led me to a successful rendering of a 'home' view. This is a much more useful place to be anyway. I do agree that there is something wrong with the AWS tutorial and posted to the AWS forums here.
If you can, you should try to access the log file; it might give you a better idea of what's going on. Here's a link that might help:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.loggingS3.title.html