標籤:django
1. Creating a project
From the command line, cd into a directory where you’d like to store your code, then run the following command:
$ django-admin startproject mysite
Let’s look at what startproject created:
mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py
2.安裝mysqlclient
pip install mysqlclient
ps:MySQLdb不能用於python3
3.Database setup?(mysql) Now, open up mysite/settings.py. It’s a normal Python module with module-level variables representing Django settings.
If you wish to use another database, install the appropriate database bindings, and change the following keys in theDATABASES ‘default‘ item to match your database connection settings:
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.mysql‘, ‘NAME‘: ‘mydb‘,‘USER‘:‘root‘,‘PASSWORD‘:‘ganbare‘,‘HOST‘:‘localhost‘,‘PORT‘:‘3306‘, }}
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
【1】依照Django官網,編寫一個web app