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

基本配置

一、创建django程序

终端命令:django-admin startproject sitename

IDE创建Django程序时,本质都是自动执行上述命令

其他常用命令:

python manage.py runserver 0.0.0.0  #运行Django,默认是127.0.0.1,如果在不同服务器上访问后面直接加本机IP

python manage.py startapp appname  #创建app,后面直接跟创建的app名称

python manage.py syncdb  #安装数据库

python manage.py makemigrations  #

python manage.py migrate

python manage.py createsuperuser

二、程序目录

Django: 之数据库完美解析

三、配置文件

安装数据库

E:\python\17\html\mysite>python manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'administrator'): root  #数据库名称
Email address:
Password:    #数据库密码
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
View Code

相关文章: