标签:manage base host 创建数据库 步骤 mysql i18n creat username
django-admin startproject projectName
django-admin startapp appName
配置mysql:
CREATE DATABASE databaseName CHARACTER SET utf8; //创建数据库,指定utf8支持中文字符
pip3 install pymsql
站点__init__.py中添加
import pymysql
pymysql.install_as_MySQLdb()
settings.py中配置:
DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.mysql‘,
‘NAME‘: ‘databaseName‘,
‘USER‘:‘userName‘,
‘PASSWORD‘:‘passwd‘,
‘HOST‘:‘‘,
‘PORT‘:‘‘,
}
}
支持中文:
LANGUAGE_CODE = ‘zh-Hans‘#‘en-us‘
TIME_ZONE = ‘Asia/Shanghai‘#‘UTC‘
USE_I18N = True
USE_L10N = True
USE_TZ = True
执行manage.py migrate
成功就OK了。
标签:manage base host 创建数据库 步骤 mysql i18n creat username
原文地址:http://www.cnblogs.com/vawter/p/6246605.html