environment: MAC_OS 10.12 Python 3.6 mysql 5.7.25 Django 2.2.3 Prerequisite: Python, Django and MySQL have been successfully installed and can be run separately 1. Database configuration in settings DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', "USER": "user name", "PASSWORD": "your password", "NAME": "db name" } } 2. Change the default database driver 1. Install pymysql 2. Replace the driver Find the main package of the project. For example, if the project is called TEST, find the __init__.py file under the TEST package. Add the following code: import pymysqlpymysql.install_as_MySQLdb() 3. Problem solving: Question 1: mysqlclient version issue """ django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. """ Solution: Follow the path in the figure to find the corresponding lines 35 and 36 and comment them out; Question 2: String encoding and decoding problem """ AttributeError: 'str' object has no attribute 'decode' """ Solution: Click on the exception tracking information, find line 146 in operations.py and change decode to encode: Test run: PS: The reason for modifying the source code is probably the compatibility issue between Django 2, Python 3 and PyMySQL. In addition, the reason for choosing 2.* is because of the official support time. The default database driver for Django is mysqlclient, but during testing, it was found that it could not run at all, and the import of various mysql libraries failed! ....... Summarize The above is the illustrated tutorial of Django2.* + Mysql5.7 development environment integration introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: In-depth understanding of React Native custom routing management
>>: Detailed explanation of the use of Linux seq command
Table of contents WebAPI DOM DOM Tree DOM element...
<br />This is not only an era of information...
This article shares the specific code of JavaScri...
Generally, click events will be divided into diff...
Sometimes it’s nice to see some nice scroll bar e...
Let me first talk about the implementation steps:...
SQL statement /* Some methods of eliminating dupl...
After the worker process is started, it will firs...
The official document states: By injecting the ro...
Overview Prometheus is an open source service mon...
Understanding of polling In fact, the focus of po...
We can create jsx/tsx files directly The project ...
A set of MySQL libraries for testing. The previou...
Table of contents 1. Installation requirements 2....
The previous article on Docker mentioned the cons...