Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Django web specifies the Chinese character set

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

When creating a simplecmdb project with django under linux, if you use Chinese encoding, you need to use the uft8 character set when creating a mysql database.

CREATE Datase`cmdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

Avoid unnecessary trouble.

If you specify a mysql database, modify the database under settings.py. The default is SQLite database.

ENGINE is the database used, name is the database, and user is the user Password is the password DATABASES = {'default': {' ENGINE': 'django.db.backends.mysql',' NAME': 'cmdb',' USER': 'root',' PASSWORD':', 'HOST':' 127.0.0.1, 'PORT':' 3306,}} LANGUAGE_CODE = 'zh-cn' / / changed to Chinese

[root@web simplecmdb] # yum install-y MySQL-python.i686 / / install mysql module if it is 64-bit, please install 64-bit.

[root@web simplecmdb] # python manage.py syncdb / / django automatically creates data synchronization data

Refer to the official document https://docs.djangoproject.com/en/1.10/topics/install/#database-installation

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report