Django-1.10.8
python2.7
Wndows/Mac
python –m pip install –r requirements.txt
brew install mysql
pip install MySQL-python
如果第二条安装出现"Failed building wheel for mysql-python"错误,则采用以下方法
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python
建库
本地mysql需要新建配置文件中的数据库
settings.py文件:
DATABASES = {
'default':{
'ENGINE':'django.db.backends.mysql',
'HOST':'127.0.0.1',
'PORT':'3306',
'NAME':'bugwrite', # 数据库名
'USER':'root',
'PASSWORD':'root',
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'"
},
}
}
cd myweb01
python manage.py makemigrations
python manage.py migrate
python manage.py runserver