Python的WEB框架有Django、Tornado、Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM、模型绑定、模板引擎、缓存、Session等诸多功能。

1、创建django程序

  • 终端命令:django-admin startproject sitename
  • IDE创建Django程序时,本质上都是自动执行上述命令

其他常用命令:

  python manage.py runserver 0.0.0.0
  python manage.py startapp appname
  python manage.py syncdb
  python manage.py makemigrations
  python manage.py migrate

  python manage.py createsuperuser

 

2、程序目录

Web框架Django(一)

 

3、配置文件

3.1 数据库

django默认配置数据库:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
View Code

相关文章:

  • 2021-06-07
  • 2022-01-07
  • 2021-11-11
  • 2021-05-20
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2021-07-18
  • 2021-11-12
  • 2021-05-03
  • 2021-07-14
  • 2022-01-20
  • 2022-12-23
相关资源
相似解决方案