Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django学习记录(六):Django by example -- Blog(二) #42

Open
PyxYuYu opened this issue Sep 19, 2016 · 0 comments
Open

Django学习记录(六):Django by example -- Blog(二) #42

PyxYuYu opened this issue Sep 19, 2016 · 0 comments
Labels

Comments

@PyxYuYu
Copy link
Owner

PyxYuYu commented Sep 19, 2016

We come nearest to the great when we are great in humility.

0x01 Django

  • Building a Blog Application

    • manage.py
      • python manage.py runserver
    usage: manage.py runserver [-h] [--version] [-v {0,1,2,3}]
                           [--settings SETTINGS] [--pythonpath PYTHONPATH]
                           [--traceback] [--no-color] [--ipv6] [--nothreading]
                           [--noreload] [--nostatic] [--insecure]
                           [addrport]
    • 默认 127.0.0.1:8000 修改如下:
      • python manage.py runserver 127.0.0.1:8001 --setting=mysite.settings
    • Project settings
      • settings.py
        • DEBUG
          • 布尔型,控制项目的 debug 模式开关,默认 True
          • 项目上线之后,需要设置成 False,否则可能泄漏敏感信息
        • ALLOWED_HOSTS
          • DEBUG 模式开或者测试时,不需要提供
          • 项目上线后,DEBUG 模式 False,需要为网站手动添加 domain/host
        • INSTALLED_APPS
          • 提供网站需求的各种应用,默认如下
          • django.contrib.admin 管理员站点
          • django.contrib.auth 用户验证框架
          • django.contrib.contenttypes 文档类型框架
          • django.contrib.sessions 会话框架
          • django.contrib.messages 消息框架
          • django.contrib.staticfiles 静态资源管理框架
        • MIDDLEWARE_CLASSES
          • 中间件,介于 requestresponse 处理之间的一道处理过程,相对比较轻量级,并且在全局上改变 django 的输入与输出,因为改变的是全局,所以需要谨慎使用,用不好会影响性能,每一个中间件都会负责一个功能,例如 AuthenticationMiddlewaresessions 处理相关
        • ROOT_URLCONF
          • 这个变量的值就是 根URLconf 的模块名,默认是 urls.py 文件的模块名
        • DATABASES
          • 字典,包含了所有项目用到的数据库的集合,默认的数据库是 SQLite3
        • LANGUAGE_CODE
          • 定义网站的默认语言编码(中文 zh_cn
    • Projects and applications
      • 一个 project 就是一个项目,一个项目可以有多个应用( app ),通用的 app 也可以在多个项目中使用
@PyxYuYu PyxYuYu added the Django label Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant