The Django version used in this blog post is 1.4.0 (recently using SAE, no way, had to withdraw from 1.7.1). But the principle is probably similar.
Django supports a variety of database management tools such as MySQL, PostgreSQL, SQLite, and Oracle. Where SQLite is built into Python, so if you use SQLite, you do not have to configure the configuration, the full use of Python to manage, of course, do not have to look at the Ben Boven.
This blog post takes MySQL as an example to demonstrate the "local environment (corresponding to the cloud environment), Django uses MySQL steps" (First make sure you have MySQL installed)
Step 1:
Modify the settings.py file in your Django project directory to resemble the following:
where ' name ' corresponds to ' db_name ' is the name of the database you created in advance using MySQL's command line prompt. Note: Before Django uses the database , you must first create the database, or you will get an error. ' User ' corresponds to ' username ' and ' PASSWORD ' corresponding to ' passwd ' is the username and password you created in MySQL . If you have more than one, just fill in a few. Both ' HOST ' and ' PORT ' can be blank by default.
Off -topic: Log in to MySQL using your username and password:
first, you need to enter the Mysql/bin directory, or you can set environment variables in. Bash_profile:
then enter passwd.
Step 2:
Then, using the Python manage.py syncdb in the manage.py path, the result will prompt you to find MYSQLDB This module incorrectly, why , because python manage.py syncdb This is how the command works:
1. Locate the app that may need to be updated in the settings.py Installed_apps tuple in the project directory.
2. Locate the models.py (relationship definition file) in each app directory and update it in the database for changes.
Said so much, the front of the error can not find the module mysqldb what is the meaning ah?
Since defining a relationship in models.py is using Python, and actually working in the database to form the model, it is certainly necessary to use SQL statements, so there must be some functional modules to translate the Python statements into SQL statements. If you use SQLite, since both SQLite and conversion modules are already built into Python, there is no error in using direct usage. But "MySQL statement conversion module" requires you to manually load, these modules are placed in the Mysql-python.
I am using pip to install:
Once installed, then use python manage.py syncdb to be OK.
The system I am using is OS X, the following is the default installation path for MySQL
/usr/local/cellar/mysql/5.6.22/bin/mysql_config
Django uses MySQL (Local environment)