1.安装python
2.python安装django
1)使用pycharm-->file-->New Project-->Django
点击create创建,等待程序安装完毕
2.安装数据库
1)配置setting
# 配置访问host
ALLOWED_HOSTS = ['*']
# 修改时区
LANGUAGE_CODE = 'zh-Hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
# 静态文件路径
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, './static'),]
# 配置数据库
# mysql配置好,且创建数据库
DATABASES = {
'default': {
'OPTIONS': {'charset': 'utf8mb4'},
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_demo',
'USER': 'django_demo',
'PASSWORD': 'django_demo',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
3.新建app
本人习惯将app放入apps里
进入apps目录下
django-admin startapp django_app
程序目录
环境:python3.7
requirements.txt
asgiref==3.2.10
Django==3.0.8
PyMySQL==0.9.3
pytz==2020.1
sqlparse==0.3.1
mysql:
修改django_demo/_init_.py
import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()