码迷,mamicode.com
首页 > 其他好文 > 详细

创建django项目

时间:2018-09-18 16:01:26      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:web   url   步骤   dmi   使用   set   返回   inter   dir   

  • wsgi -- Web Server Gateway Interface
    •   用来处理client端和server端之间的TCP连接、HTTP原始请求和响应格式

 

  • 创建项目的步骤
    • 安装django:
      •   pip3 install django
    • 创建project:
      •   django-admin startproject mysite
    • 创建app:
      •   python mannage.py startapp app01
    • settings配置:
      •   TEMPLATES:
        •   ‘DIRS‘: [os.path.join(BASE_DIR, ‘templates‘)]
        •   STATIC_URL = /static/
      •   INSTALLED_APPS:
        •   加入‘app01‘,然后再同步数据库
    • 生成同步数据库的脚本:
      •   python manage.py makemigrations
    • 同步数据库::
      •   python manage.py migrate
    • 设计代码:urls.py  views.py
    • 返回http响应:
      •   from django.shortcuts import HttpResponse
      •   return HttpResponse()
    • 使用模板:
      •   from django.shortcuts import render
      •   return render(req, "index.html")
    • 启动项目:
      •   python manage.py runserver  127.0.0.1:8090

创建django项目

标签:web   url   步骤   dmi   使用   set   返回   inter   dir   

原文地址:https://www.cnblogs.com/dongmengze/p/9668939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!