#TODO: Add debug toolbar
$ sudo pip3 install pipenv
$ pipenv --python 3.6
pipenv shell
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"
$ pipenv install
$ pipenv shell
$ django-admin startproject config
$ python manage.py startapp core
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
In the terminal start the local web server.
$ python manage.py runserver $IP:$PORT
To stop the server, in the terminal press CTRL + D
.
python runtests.py
coverage run --source='.' runtests.py
coverage report -m
coverage html
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
Set heroku Env Var DJANGO_SETTINGS_MODULE
to config.settings.production
.