This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make sure DEBUG is false | |
DEBUG = False | |
TEMPLATE_DEBUG = DEBUG | |
# Put it at the end of the settings | |
try: | |
# Load the local settings | |
from local_settings import * | |
except ImportError: | |
# Load the settings for Heroku | |
# Parse database configuration from $DATABASE_URL | |
import dj_database_url | |
DATABASES = { | |
'default': dj_database_url.config() | |
} | |
# Honor the 'X-Forwarded-Proto' header for request.is_secure() | |
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | |
# Allow all host headers | |
ALLOWED_HOSTS = ['*'] | |
# Static asset configuration | |
import os | |
#BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
BASE_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../') | |
STATIC_ROOT = 'staticfiles' | |
STATIC_URL = '/static/' | |
STATICFILES_DIRS = ( | |
os.path.join(BASE_DIR, 'static'), | |
) |
Troubleshooting for dj-static (In case static files error)wsgi.py
OSError: [Errno 2] No such file or directory: '/app/PROJECT_NAME/static'
heroku run python manage.py collectstatic --dry-run --noinput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
WSGI config for autograph_test project. | |
This module contains the WSGI application used by Django's development server | |
and any production WSGI deployments. It should expose a module-level variable | |
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover | |
this application via the ``WSGI_APPLICATION`` setting. | |
Usually you will have the standard Django WSGI application here, but it also | |
might make sense to replace the whole Django WSGI application with a custom one | |
that later delegates to the Django one. For example, you could introduce WSGI | |
middleware here, or combine a Django application with an application of another | |
framework. | |
""" | |
import os, sys | |
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../') | |
if path not in sys.path: | |
sys.path.append(path) | |
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks | |
# if running multiple sites in the same mod_wsgi process. To fix this, use | |
# mod_wsgi daemon mode with each site in its own daemon process, or use | |
# os.environ["DJANGO_SETTINGS_MODULE"] = "autograph_test.settings" | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PROJECT_NAME.settings") | |
# This application object is used by any WSGI server configured to use this | |
# file. This includes Django's development server, if the WSGI_APPLICATION | |
# setting points here. | |
from django.core.wsgi import get_wsgi_application | |
from dj_static import Cling | |
application = Cling(get_wsgi_application()) | |
# Apply WSGI middleware here. | |
# from helloworld.wsgi import HelloWorldApplication | |
# application = HelloWorldApplication(application) |
Procfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: gunicorn PROJECT_NAME.wsgi |
runtime.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python-2.7.4 |
requirements.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Django==1.5.1 | |
South==0.8.1 | |
dj-database-url==0.2.2 | |
dj-static==0.0.5 | |
gunicorn==17.5 | |
pil==1.1.7 | |
psycopg2==2.5.1 | |
static==0.4 | |
wsgiref==0.1.2 |
Related Cmd
ssh-keygen -t rsa
# Generate ssh pub key (id_rsa)
ssh -v git@github.com
# Check your default .pub location for troubleshooting
# Make sure both files included in the directory (id_rsa & id_rsa.pub)
More info: https://devcenter.heroku.com/articles/keys
heroku login
heroku keys
heroku keys:remove xxx@xxx
echo local_settings.py>> .gitignore
# Remember to exclude local_settings.py in .gitignore
More info: https://devcenter.heroku.com/articles/gitignore
git add .
git commit -m 'Initial commit'
git remote -v
git remote rm heroku
More info: https://devcenter.heroku.com/articles/git
heroku create APP_NAME OR heroku git:remote -a EXISTING_APP_NAME
heroku addons | grep POSTGRES
heroku addons:add heroku-postgresql:dev
heroku pg:wait
heroku config | grep HEROKU_POSTGRESQL
heroku pg:promote HEROKU_POSTGRESQL_XXX_URL
# Replace XXX with info from heroku config
More info: https://devcenter.heroku.com/articles/heroku-postgresql
heroku open
heroku run python manage.py syncdb
heroku run python manage.py migrate APP
heroku run python manage.py shell
More info: https://devcenter.heroku.com/articles/django
No comments :
Post a Comment