1.安裝postgresqlpython
安裝命令:brew install postgresqlsql
啓動服務命令:pg_ctl start -D /usr/local/var/postgres(暫時未搞懂命令的含義)數據庫
中止服務命令:pg_ctl stop -D /usr/local/var/postgresdjango
建立當前用戶默認數據庫:create (dbname) -O (username)app
訪問數據庫:psqlpost
建立django須要使用的數據庫:測試
create user (username) with password '(password)'spa
create database (databasename) owner (username) encoding 'utf-8'3d
退出postgresql爲\q命令rest
2.安裝python:brew install python
3.安裝virtualenv
$easy_install pip(此步驟需在root權限下執行。獲取root權限 sudo -i然後輸入密碼)
$pip install virtualenv
$virtualenv myenv
$cd myenv
$. bin/activate(暫時未解決)
4.安裝django
$pip install django
$pip install psycopg2
$pip install djangorestframework
5.測試
創建名爲myapp的工程:django-admin.py startproject myapp
創建好的工程目錄以下:
編輯myapp/myapp/settings.py,修改數據庫配置:
啓動myapp/manage.py:python manage.py runserver 0.0.0.0:8000
雖有bug,但打卡http://localhost:8000可運行