Django Learning (1)--python manage.py startapp app-name new app error problem

Source: Internet
Author: User

As a little white with Python, starting to learn Django is doomed to a long way, documenting the learning process problems and solutions.

Thanks to the selfless dedication of the "self-Improvement Academy", after installing Django 1.9.12 in the tutorial, try to create a new project with Python manage.py Startapp App-name has been unable to build the app. The last line of the error is "Django.core.exceptions.ImproperlyConfigured:Error loading either Pysqlite2 or Sqlite3 modules (tried in or Der): No module named _sqlite3 "As a small white, direct Baidu a little bit of this sentence, found no SQLite database. No, I'm supposed to be connected to the MySQL database.

Continue Baidu.

The settings for the database in Django are in the settings.py file. Open the file found inside the main configuration are linked to the official website, decisive officer NET, find the database configuration as follows:

# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases


DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.sqlite3 ',
' NAME ': Os.path.join (Base_dir, ' db.sqlite3 '),
}
}

According to the guidance of the official website, the database engine was changed to MySQL, and the relevant configuration.

DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' * * * ', #数据库名
' USER ': ' * * * ', #数据库用户名
' PASSWORD ': ' ******* ', #数据库密码
' HOST ': ' 127.0.0.1 ',
' PORT ': ' 3306 ',
}
}

After backing up the original file and modifying it, try to execute Python manage.py startapp app-name continue to error .... "No module named MySQLdb". Well, I've already installed the Pymysql, or I'll put a mysqldb on it. Various YUM/PIP installations are unsuccessful. Not very patient, mainly is the Pymysql is the MYSQLDB upgrade version, should be able to use only.

Continue Baidu.

Find the method.

In the site's __init__.py file, add the following code:

1 Import pymysql2 pymysql.install_as_mysqldb ()

After configuration, execute Python manage.py startapp app-name no longer error, open folder, app has been established. Problem solving.

Django Learning (1)--python manage.py startapp app-name new app error problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.