美文网首页
Django基本知识

Django基本知识

作者: Seinist | 来源:发表于2018-09-24 22:32 被阅读0次

开发环境

Mac + python3

资料

https://docs.djangoproject.com/en/2.1/

项目初始化

django-admin startproject $project_name
python3 manage.py startapp $app_name
python3 manage.py runserver 0.0.0.0:$port
#1.一个project中包含若干个apps,每个app需要在project的目录下的settings.py中注册
#2.django的默认数据库是自带的

强大的 manage.py

1.manage.py会在新建项目后自动生成

python3 manage.py help
Type 'manage.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[contenttypes]
    remove_stale_contenttypes

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[sessions]
    clearsessions

[staticfiles]
    collectstatic
    findstatic
    runserver

利用 manage.py shell 调试api

python3 manage.py shell

相关文章

网友评论

      本文标题:Django基本知识

      本文链接:https://www.haomeiwen.com/subject/gsihoftx.html