Access application from 'https://djangodemo-pritimay.c9users.io/' and the admin page from 'https://djangodemo-pritimay.c9users.io/admin'.
https://vast-taiga-70981.herokuapp.com/
-
Run syncdb command to sync models to database and create Django's default superuser and auth system
$ python manage.py migrate
-
Run Django
$ python manage.py runserver $IP:$PORT
-
Create superuser for with admin role for the application
python manage.py createsuperuser
-
Install postgres using
sudo apt-get update
sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib
-
Make migrations
python manage.py makemigrations
-
Install psycopg2
sudo pip install psycopg2
-
Create Database
CREATE DATABASE djangodemo;
-
Create database user to connect and interact with database
CREATE USER djangodemouser WITH PASSWORD 'password';
-
Add encoding, trasaction scheme and timezone
ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myprojectuser SET timezone TO 'UTC';
-
Give user rights to the create database
GRANT ALL PRIVILEGES ON DATABASE djangodemo TO djangodemouser;
-
Postgre shell
$ sudo su - postgres
-
Run Sql query
$ psql -h localhost -d djangodemo -U djangodemouser -W
-
Exit sql prompt
\q
-
Exit out of postgres shell
exit
-
Add app issues
$ python manage.py startapp issues
-
Start postgres
$ sudo service postgresql start
-
Start postgres at boot
$ sudo update-rc.d postgresql enable
-
Install rest_framework 3.6.4 since >=3.7 is not supported for django 1.9
$ sudo pip install rest_framework==3.6.4
-
Deployment in heroku. Login first, and then
heroku create
-
Heroku
DISABLE_COLLECSTATIC
using$ heroku config:set DISABLE_COLLECTSTATIC=1
-
Add Procfile and
web: gunicorn djangodemo.wsgi
-
Add requirements.txt file
pip freeze > requirements.txt
-
Add
django-heroku
andgunicorn
-
Write in settings file
import django_heroku
django_heroku.settings(locals())
-
Heroku url
-
Push db
heroku pg:push djangodemo DATABASE_URL --app vast-taiga-70981
-
Connect db
heroku pg:psql
-
Export db url
export DATABASE_URL=postgres://$(whoami)