$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install postgresql
$ pg_ctl start -D /usr/local/var/postgres
$ pg_ctl stop -D /usr/local/var/postgres
$ createdb <dbname> -O <username>
比如
$ createdb kongxx -O kongxx
$ psql
$ psql
kongxx=# CREATE USER admin WITH PASSWORD ‘Letmein‘;
kongxx=# CREATE DATABASE test OWNER admin ENCODING ‘UTF8‘;
$ brew install python
$ easy_install pip
$ pip install virtualenv
$ virtualenv myenv
$ cd myenv
$ . bin/activate
$ pip install django
$ pip install psycopg2
$ pip install djangorestframework
# django-admin.py startproject myapp
修改数据库配置,编辑 myapp/myapp/settings.py
DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.postgresql_psycopg2‘,
‘NAME‘: ‘test‘,
‘USER‘: ‘admin‘,
‘PASSWORD‘: ‘Letmein‘,
‘HOST‘: ‘127.0.0.1‘,
‘PORT‘: ‘5432‘,
}
}
# cd myapp
# python manage.py runserver 0.0.0.0:8000
然后访问 http://localhost:8000 即可看到 django 已经可以工作了。
转载请以链接形式标明本文地址
本文地址:http://blog.csdn.net/kongxx/article/details/49365973
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/kongxx/article/details/49365973