下面是簡略的配置,重點是Django配置Postgresql,由於Django使用pq須要psycopg2,重點是模塊psycopg2的依賴模塊!python
sudo aptitude install update sudo aptitude install upgrade
sudo aptitude install python-pip
sudo pip install django==1.8
sudo aptitude install postgresql-9.3
1.安裝環境依賴sql
sudo aptitude install python-dev libpq-dev
2.安裝模塊數據庫
sudo pip install psycopg2
psql# create user abc with 'abc'; #新建用戶abc,密碼abc psql# create database abc owner abc; #新建數據庫及其屬主 abc
修改配置權限,不然沒法初始化PG(本文最後一步)django
sudo vim /etc/postgresql/9.3/main/pg_hba.conf
將85,90,92行行末的peer和MD5,修改成trust(信任)vim
保存退出post
project_name: aspa
修改配置文件 a/a/settings.pypostgresql
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME':'abc', #數據庫名 'USER': 'abc', #數據庫用戶名 'PASSWORD': 'abc', #數據庫用戶名密碼 'HOST': '', 'PORT': '5432', #數據庫遠程鏈接端口 } }
配置完後,code
執行 ip
python manage.py migrate
初始化數據庫
http://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python
http://stackoverflow.com/questions/32123068/pycharm-django-postgresql