Deploying to Heroku with Anaconda

前端 未结 3 736
盖世英雄少女心
盖世英雄少女心 2020-12-29 05:27

I have a Django app I want to deploy to Heroku. I tried to follow the instructions here: https://devcenter.heroku.com/articles/getting-started-with-django which tells you to

3条回答
  •  我在风中等你
    2020-12-29 05:51

    If you are in conda environment then using these steps might help to deploy your Django app to Heroku:

    Before deploying, make the following four changes to your project so it’s ready to deploy online with Heroku:

    1. Install gunicorn as your web-server. ( Since, you are using conda environment gunicorn is not currently available at any conda channels to install. So, use pip install gunicorn )
    2. Add requirements.txt file to your project's base directory and inside it add the modules names along with it versions or simply copy the contents that you get after you run pip freeze command.
    3. Make a new file: Procfile & inside it add the following:

      web: gunicorn [Project_name].wsgi --log-file -

      (Here [Project_name] is your own project's directory name)

      This says to use your existing [Project_name].wsgi file but with gunicorn.

    4. Make just a single change to settings.py file:

      ALLOWED_HOSTS = ['*']

      ( The wildcard Asterisk * means all domains are acceptable to keep things simple. )

    Now finally you can deploy using these steps:

    • Create a new app on Heroku: On CLI type heroku create

      (Heroku will create a random name for your app; [your_app_name])

    • Add a git remote “hook” for Heroku:

      heroku git:remote -a [your_app_name]

    • Ignore static files:

      heroku config:set DISABLE_COLLECTSTATIC=1

    • Push our code to Heroku:

      git push heroku master

    • Finally, make your Heroku app live:

      heroku ps:scale web=1

    ( Here, web=1 for basic Heroku services )

    To open your app: heroku open

    Your app should now be live on Heroku.

提交回复
热议问题