Step 1: connect to the database
Development Environment: Ubuntu
Modify settings. py
DATABASES = {
'Default ':{
'Engine': 'django. db. backends. mysql', & nbsp;
'Name': 'blog ', & nbsp;
& Nbsp;
'User': 'root ',
'Password': 'root ',
'Host': '2017. 0.0.1 ', & nbsp;
'Port': '123', & nbsp;
}
}
Test:
>>> From django. db import connection
>>> Cursor = connection. cursor ()
No error. Connection successful!
Step 2: Management Interface Chinese submission error:
In settings. py of the Project root directory to be modified in django Configuration:
TIME_ZONE = 'America/Chicago'
Required age_code = 'en-us'
Replace:
TIME_ZONE = 'Asia/Shanghai'
Export age_code = 'zh-cn'
In the Python installation path:/usr/local/lib/python2.7/dist-packages/django/conf/global_settings.py:
TIME_ZONE = 'America/Chicago'
Required age_code = 'en-us'
Replace:
TIME_ZONE = 'Asia/Shanghai'
Export age_code = 'zh-cn'
More TIME_ZONE
Http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
File encoding change (global_settings.py ):
DEFAULT_CHARSET = 'utf-8'
FILE_CHARSET = 'utf-8'
After modification, the problem cannot be solved, but the management interface is changed to Chinese, and the Chinese submission is still incorrect! The possible cause is the encoding of the database. re-create the database and add the encoding:
Create database blog character set utf8;
Chinese characters are supported.
Django details: click here
Django's: click here
Recommended reading:
Install Nginx + uWSGI + Django on Ubuntu Server 12.04
Django tutorial
Build a Django Python MySQL Linux development environment