How to deploy mezzanine on heroku? - django

I have created a mezzanine project and its name is mezzanine-heroku-test
I create a Procfile that has the content as follow:
web: python manage.py run_gunicorn -b "0.0.0.0:$PORT" -w 3
Next, I access to the website to test and I receive the error: Internal Server Error.
So, Could you please help me deploy mezzanine on heroku step by step or some suggestion?
Thank you so much.

You should be able to see the error in the logs which you can get to using the heroku tool.
heroku logs

These are both thorough.
https://gist.github.com/joshfinnie/4046138
http://www.benhavilland.com/blog/deploying-mezzanine-on-heroku/
This is a challenging process.

Related

How to start a django project on one that is already created?

I already have a django project and all files created, but I am trying to deploy to a server. I moved files over to server using FileZilla and I am in putty now trying to django-admin startproject practice ~/practice but I get a command error stating that this already exists which obviously it does but then if I want to manage.py makemigrations I get a -bash: Permission denied and I am guessing that is because I have not started django project here on putty??? I hope there is enough info here to explain my issue. Any help is appreciated
You need run python manage.py runserver in the correct folder with admin permisions.

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type' QGIS Docker container to Heroku

There is a really old thread on stackoverflow here Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb
but the difference that I have with their issue is that my containers have the POSTGIS and POSTGRES installed in. Specifically I used QGIS and the image is like so
db:
image: kartoza/postgis:13.0
volumes:
- postgis-data:/var/lib/postgresql
So locally I have two docker images - one is web and the other is the kartoza/postgis
I also have this as well in the settings.py file
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
which should support the GIS data. I see all my packages gis, geolocation packages installed with no issues. But I am getting the above error when I run heroku run python manage.py migrate
The website runs with very limited functionality as the geo variables are needed to get you past the landing page.
The steps I have taken to deploy is
heroku create appname
heroku stack:set container -a appname
heroku addons:create heroku-postgresql:hobby-dev -a appname
heroku git:remote -a appname
git push heroku main
EDIT The db url on heroku is postgres://foobar:3242q34rq2rq32rf3q2rfq2q2r3vq23rvq23vr#er3-13-234-91-69.compute-
I have also ran the below command and it shows that the db now takes GIS, but I still get the error
$ heroku pg:psql
create extension postgis;
try replacing db with localhost
heroku config:add DATABASE_URL=postgis://foo:bar#localhost:5432/gis
Ok so after 14 or so hours of reading. The issue here is that
Heroku database does NOT have qgis capabilities enabled as a default - you have to use heroku pg:psql then run CREATE EXTENSION postgis;
Having QGIS installed within the docker container results it not being able to perform functions such as hero pg:push localdatabase -postgresqlremoteherokudb and heroku config:add DATABASE_URL=postgis://foo:bar#localhost:5432/gis So if anyone is following the python nearbyshops tutorial, you might end up here as well. I got fixated here thinking it's a db issue, but it was more so to do with heroku configuration settings.
If you are coming here from docker, which might mean you need to install django_heroku package to modify your settings. There are recent 2019 and 2018 guides on how to deploy Geospatial apps to heroku, but again, you don't need those. (at least for me I didn't)
GIS now is available as an extension, you no longer need to add buildpacks.
There are still some configuration issues if you are using gunicorn for staticfiles, so the website at first won't launch properly. Highly suggest that you track your heroku log errors (manual settings.py coding or heroku addons).

Error during deploying django app in Heroku

I am trying to deploy a Django application to Heroku. When I followed the documentation and tried the command git push heroku master, I am getting an error: failed to push some refs to 'https://git.heroku.com/sleepy-eyrie-25993.git'. I searched online and tried to use git pull. But it didn't work. I also tried using git push -f heroku master, but still getting the same error. Is there any other way to do it? I followed this doc
https://devcenter.heroku.com/articles/python-support.
Tried using the heroku dashboard, but it is giving the same error
Building on the Heroku-18 stack ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push failed
You can also deploy from your application dashboard on Heroku
Heroku deployment requires requirements.txt in the root of the repository.
Also, to run a Django app - it requires file Procfile
Sample content:
web: gunicorn your_app_name.wsgi:application --log-file -
You can also try to specify buildpack manually by executing:
heroku buildpacks:set heroku/python
Then if there are additional errors starting - they will be more specific
Also settings.py of your Django application should contain the following:
import django_heroku
django_heroku.settings(locals())
For more details, please refer Here

How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?

I'm trying to get deploy a simple django app, and have successfully pushed my git repository to Heroku. However, when I attempt to run:
heroku ps:scale web=1
I get the following error
Scaling dynos... failed
! Couldn't find that formation.
Any thoughts as to what the problem might be? The contents of the Procfile (below) are correct to the best of my knowledge.
web: gunicorn my_app_name.wsgi
To state the obvious: another way to encounter this issue is if you're working on a new app, and you try running heroku ps:scale web=1 before you've actually done a git push heroku master. There is no Procfile on the Heroku server in that case, because there aren't any files at all. :D
Ensure that your Procfile has no extension.
To create a file with no extension on Windows, you can use the command notepad Procfile. from the command line.
To add yet another reason this can happen, my Procfile contained
web:gunicorn
but it should be:
web: gunicorn
As far as I can tell from all of these answers, if you run into this problem, it is very likely related to Procfile.
for those interested, I had the same problem to add a worker. to do so you need to add this line to your procfile : worker: python worker.py
For others experiencing this same issue, make sure Procfile is not ignored in git.
Delete your Procfile. Then git status. If don't see anything mentioning Procfile, you need to find remove the entry from local or global .gitignore.
I faced a similar issue while working on windows(haven't tested on other operating systems)and this worked fine for me.
Initially, I have created a file name procfile and pushed it to heroku. But, heroku expects the Procfile declaration. It is case sensitive. Hence, we should be careful while typing the filename also.
Even after changing the name to Procfile git didnt notice changes(maybe git is case-insensitive just like windows). Hence, I had to delete the file completly and had to create a new one with Procfile as the name of the file.
I had the same problem because I missed git add and git commit the file named Procfile .
You should try to use the command git status and review whether the Procfile is included.
When pushing to Heroku you must come up with something like shown in the Picture. If not your procfile has an Error.
The Procfile looks like this for my Flask app
web: gunicorn app:app
In my php project I can use
$ heroku ps:scale web=1
at the heroku directory "php-getting-started" (https://devcenter.heroku.com/articles/getting-started-with-php#prepare-the-app).
So I'm try to do this in my original application, so I tried to do again in Heroku Repository and it's work.
(sorry about the english, hehe)
I got the same problme,
1) I also configured ProcFile
but the problem still available
So used this
Remove the existing buildpacks with heroku buildpacks:clear and add them again in the right order using the heroku buildpacks:add with the --index option, making sure that the language buildpack is the last in the list
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
Problem solved
I had a similar problem and tried the following:
Made sure Procfile does not have any extension
Procfile is spelled exactly as 'Procfile'
At the end of the day just realized that my Procfile was in my app directory. It should be on the root/project directory.

Heroku: My Django app is giving Application Error H14: "No Web Processes Running"

According to the Heroku site when I get error H14 "No Web Processes Running" it's because I need to scale up dynos by:
heroku ps:scale web=1
However, when I do that I get the following error:
Scaling web processes... failed
! No such type as web
Does anyone know how to fix this? I want to get my site back up!
When I run heroku ps I see nothing.
UPDATE: It's not detecting my Procfile. I don't have a Procfile explicitly and didn't use one before... is it absolutely necessary?
I ran into this recently as well, my web was working fine without any Procfile, until recently...
My fix was simply to add a Procfile as follows:
web: python manage.py runserver 0.0.0.0:$PORT --noreload
Then push to heroku.
For Heroku you need to add a Procfile.
add a Procfile on same level like your manage.py file. It should be in your root directory. Be sure that you create a Procfile not a Procfile.txt or else just Procfile
in your Procfile add:
web: gunicorn projectname.wsgi
add in your requirements.txt gunicorn
gunicorn==20.0.4
If you activate automatic deploy you can try it again.
If you can remove the app, remove it and deploy it again.