Tuesday, 3 May 2016

Configure PostgreSQL With Django Application

# su - postgres
$psql
# CREATE DATABASE projectdata;
#CREATE USER projectdatauser WITH PASSWORD ‘password’;
#ALTER ROLE projectdatauser SET client_encoding TO ‘utf8’;
#GRANT ALL PRIVILEGES ON DATABASE projectdata TO projectdatauser;
#\q
$exit
#django-admin.py startproject djangoproject
#vim djangoproject/djangoproject/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'projectdata',                     
        'USER': 'projectdatauser',                     
        'PASSWORD': 'password',                 
        'HOST': 'localhost',                     
        'PORT': '5433',                     
    }
}


save and exit
#cd  djangoproject
#./manage.py syncdb
#python manage.py runserver

No comments:

Post a Comment