Skip to content

MrGallo/django-heroku-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#TODO: Add debug toolbar

Set up c9 workspace

$ sudo pip3 install pipenv
$ pipenv --python 3.6

Use the PipEnv

pipenv shell

Start New Project

Create a directory for your project

$ mkdir projectname
$ cd projectname

Create a Pipfile

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true


[packages]
django = "*"
gunicorn = "*"
psycopg2-binary = "*"
django-heroku = "*"
redgreenunittest = "*"
coverage = "*"
mixer = "*"


[requires]
python_version = "3.6"

Install requirements

$ pipenv install
$ pipenv shell

Create the Django project

$ django-admin startproject config

Create the core application

$ python manage.py startapp core

Config the database

In the config/settings.py file change DATABASES to:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'app_name',
        'USER': 'app_name',
        'PASSWORD': 'development',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

In the terminal:

$ psql
ubuntu=# CREATE DATABASE app_name;
ubuntu=# CREATE USER app_name;
ubuntu=# GRANT ALL ON DATABASE app_name to "app_name";
ubuntu=# ALTER USER app_name PASSWORD 'development';
ubuntu=# ALTER USER app_name CREATEDB;

Press CTRL + d to exit the psql shell.

If database shuts down, sudo service postgresql restart

Verify setup

In the terminal start the local web server.

$ python manage.py runserver $IP:$PORT

To stop the server, in the terminal press CTRL + D.

Testing

python runtests.py coverage run --source='.' runtests.py coverage report -m coverage html

Deploy

Following files must be at top level of repository.

Pipfile
Pipfile.lock
Procfile

If Procfile is at top level and not in the same folder as manage.py, edit the Procfile:

web: gunicorn --chdir django config.wsgi

Multiple settings files

Article here

Set heroku Env Var DJANGO_SETTINGS_MODULE to config.settings.production.

Multiple Heroku Environments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages