Skip to content

Instantly share code, notes, and snippets.

@Jbot29
Last active July 5, 2016 08:35
Show Gist options
  • Save Jbot29/ce6ed6abff04d0ae34e5 to your computer and use it in GitHub Desktop.
Save Jbot29/ce6ed6abff04d0ae34e5 to your computer and use it in GitHub Desktop.

Revisions

  1. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -74,6 +74,7 @@ DATABASES['default'].update(db_from_env)
    import os

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    STATIC_URL = '/static/'

    STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
  2. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -65,13 +65,15 @@ Update the <project dir>/settings.py file based on the link below under Django S
    Place at the bottom of settings.py

    import dj_database_url

    db_from_env = dj_database_url.config(conn_max_age=500)

    DATABASES['default'].update(db_from_env)


    import os


    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    STATIC_URL = '/static/'

    STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
  3. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -52,6 +52,12 @@ Install any pip modules you need

    > pip freeze > requirements.txt
    add

    psycopg2==2.6.1

    to requirements doc

    #Settings changes

    Update the <project dir>/settings.py file based on the link below under Django Settings
  4. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -119,7 +119,10 @@ Setting environment var in the shell/terminal
    #Setting Enviornement Variables on Heroku

    > heroku config:set SECRET_KEY=8N029N81 S3_SECRET=9s83109d3+583493
    > heroku config:set SECRET_KEY=8N029N81
    S3_SECRET=9s83109d3+583493
    ...

    Notes:
    https://devcenter.heroku.com/articles/config-vars
  5. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -70,7 +70,6 @@ STATIC_URL = '/static/'

    STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')

    # Extra places for collectstatic to find static files.
    STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    ]
  6. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -59,14 +59,12 @@ Update the <project dir>/settings.py file based on the link below under Django S
    Place at the bottom of settings.py

    import dj_database_url

    if os.environ.has_key('DATABASE_URL') and dj_database_url.config():
    DATABASES['default'] = dj_database_url.config()
    db_from_env = dj_database_url.config(conn_max_age=500)
    DATABASES['default'].update(db_from_env)


    import os

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))

    STATIC_URL = '/static/'

  7. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -81,7 +81,6 @@ STATICFILES_DIRS = [
    STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'



    Notes:
    https://devcenter.heroku.com/articles/getting-started-with-django#django-settings

  8. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -68,16 +68,20 @@ import os

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))

    STATIC_ROOT = 'staticfiles'

    STATIC_URL = '/static/'

    STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    )
    STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')

    # Extra places for collectstatic to find static files.
    STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    ]


    STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'



    Notes:
    https://devcenter.heroku.com/articles/getting-started-with-django#django-settings

  9. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -144,7 +144,7 @@ create an admin super user

    > heroku run python manage.py createsuperuser
    #Create new secret key
    #Create new secret key (only if secret was pushed to a public git hub)

    http://www.miniwebtool.com/django-secret-key-generator/

  10. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -114,6 +114,7 @@ SECRET_KEY = os.environ.get('SECRET_KEY')
    Setting environment var in the shell/terminal

    > export SECRET_KEY=myawesomekey
    > env
    #Setting Enviornement Variables on Heroku
  11. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -99,12 +99,6 @@ application = DjangoWhiteNoise(application)

    > heroku create
    #Push code to Heroku

    > add all new files to git
    > git push heroku master
    #Setting Environment variables

    Environment variables locally
    @@ -129,6 +123,14 @@ Setting environment var in the shell/terminal
    Notes:
    https://devcenter.heroku.com/articles/config-vars

    #Push code to Heroku

    > add all new files to git
    > git push heroku master


    #Run Migration on heroku

    First add basic postgres on heroku site
  12. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -86,9 +86,12 @@ https://devcenter.heroku.com/articles/getting-started-with-django#django-setting
    Update <project dir>/wsgi.py per the instructions

    from django.core.wsgi import get_wsgi_application

    from whitenoise.django import DjangoWhiteNoise


    application = get_wsgi_application()

    application = DjangoWhiteNoise(application)


  13. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,10 @@ In the directory where manage.py lives run:
    > pip install dj-database-url
    > pip install whitenoise
    > pip install psycopg2
    Pip install any modules that you need - Examples
    requests
    BeautifulSoup
  14. Jbot29 revised this gist Feb 29, 2016. 1 changed file with 2 additions and 18 deletions.
    20 changes: 2 additions & 18 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,6 @@
    #Create new git repo

    #Brew & Postgress Install

    Mac:

    Terminal:

    > ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    > brew install postgresql
    Ubuntu:

    https://help.ubuntu.com/community/PostgreSQL

    Notes:

    http://brew.sh/
    http://braumeister.org/formula/postgresql
    At the same level as manage.py

    #Create Heroku account

  15. Jbot29 revised this gist Feb 26, 2016. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -40,6 +40,8 @@ In the directory where manage.py lives run:
    > source venv/bin/activate
    > pip install django
    > pip install gunicorn
    > pip install dj-database-url
    @@ -86,6 +88,8 @@ STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    )

    STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

    Notes:
    https://devcenter.heroku.com/articles/getting-started-with-django#django-settings

    @@ -94,19 +98,20 @@ https://devcenter.heroku.com/articles/getting-started-with-django#django-setting
    Update <project dir>/wsgi.py per the instructions

    from django.core.wsgi import get_wsgi_application
    from whitenoise.django import DjangoWhiteNoise

    from dj_static import Cling
    application = get_wsgi_application()
    application = DjangoWhiteNoise(application)

    application = Cling(get_wsgi_application())

    Note: this line replaces application = get_wsgi_application()

    #Create new Heroku app

    > heroku create
    #Push code to Heroku

    > add all new files to git
    > git push heroku master
    #Setting Environment variables
  16. Jbot29 revised this gist Feb 26, 2016. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -41,11 +41,12 @@ In the directory where manage.py lives run:
    > source venv/bin/activate
    > pip install gunicorn
    > pip install dj-database-url
    Pip install any modules that you need
    ex: requests
    ex: BeautifulSoup
    Pip install any modules that you need - Examples
    requests
    BeautifulSoup

    #Create Procfile

  17. Jbot29 revised this gist Feb 26, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,8 @@ In the directory where manage.py lives run:
    > source venv/bin/activate
    > pip install django-toolbelt
    > pip install gunicorn
    > pip install dj-database-url
    Pip install any modules that you need
    ex: requests
  18. Jbot29 revised this gist Feb 26, 2016. 1 changed file with 0 additions and 12 deletions.
    12 changes: 0 additions & 12 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -54,18 +54,6 @@ put the line below in that file

    web: gunicorn django project name.wsgi --log-file -

    If you do not have foreman

    sudo gem install foreman

    Try starting the server with

    > foreman start
    You will see a popup - hit allow

    got to localhost:5000 in your browser to test

    #Install all pip requirements

    Install any pip modules you need
  19. Jbot29 revised this gist Feb 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ Create a file called Procfile with upper case P in the same directory with mana

    put the line below in that file

    web: gunicorn <django project name>.wsgi --log-file -
    web: gunicorn django project name.wsgi --log-file -

    If you do not have foreman

  20. Jbot29 revised this gist Oct 28, 2015. No changes.
  21. Jbot29 revised this gist Oct 28, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -104,6 +104,7 @@ https://devcenter.heroku.com/articles/getting-started-with-django#django-setting
    Update <project dir>/wsgi.py per the instructions

    from django.core.wsgi import get_wsgi_application

    from dj_static import Cling

    application = Cling(get_wsgi_application())
  22. Jbot29 revised this gist Oct 28, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -85,8 +85,11 @@ if os.environ.has_key('DATABASE_URL') and dj_database_url.config():


    import os

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))

    STATIC_ROOT = 'staticfiles'

    STATIC_URL = '/static/'

    STATICFILES_DIRS = (
  23. Jbot29 revised this gist Oct 28, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ Create a file called Procfile with upper case P in the same directory with mana

    put the line below in that file

    web: gunicorn django project name.wsgi --log-file -
    web: gunicorn <django project name>.wsgi --log-file -

    If you do not have foreman

  24. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -124,6 +124,7 @@ Using it in Django settings.py
    in settings.py - using env var

    import os

    SECRET_KEY = os.environ.get('SECRET_KEY')

    Setting environment var in the shell/terminal
  25. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -140,6 +140,8 @@ https://devcenter.heroku.com/articles/config-vars

    #Run Migration on heroku

    First add basic postgres on heroku site

    > heroku run python manage.py migrate
    #Create admin user
  26. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,10 @@ In the directory where manage.py lives run:
    > pip install django-toolbelt
    Pip install any modules that you need
    ex: requests
    ex: BeautifulSoup

    #Create Procfile

    Create a file called Procfile with upper case P in the same directory with manage.py
  27. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,10 @@ put the line below in that file

    web: gunicorn django project name.wsgi --log-file -

    If you do not have foreman

    sudo gem install foreman

    Try starting the server with

    > foreman start
  28. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ Create a file called Procfile with upper case P in the same directory with mana

    put the line below in that file

    web: gunicorn <django project name>.wsgi --log-file -
    web: gunicorn django project name.wsgi --log-file -

    Try starting the server with

  29. Jbot29 revised this gist Aug 19, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,8 @@ Download the heroku toolbelt and install:

    https://toolbelt.heroku.com/

    Run the package file.

    #Create Virtual Environment

    In the directory where manage.py lives run:
  30. Jbot29 revised this gist Aug 18, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions DjangoHerokuDeploy.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,18 @@

    #Brew & Postgress Install

    Mac:

    Terminal:

    > ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    > brew install postgresql
    Ubuntu:

    https://help.ubuntu.com/community/PostgreSQL

    Notes:

    http://brew.sh/