zoukankan      html  css  js  c++  java
  • 创建django项目

    • wsgi -- Web Server Gateway Interface
      •   用来处理client端和server端之间的TCP连接、HTTP原始请求和响应格式
    • 创建项目的步骤
      • 安装django:
        •   pip3 install django
      • 创建project:
        •   django-admin startproject mysite
      • 创建app:
        •   python manage.py startapp app01
      • settings配置:
        •   TEMPLATES:
          •   'DIRS': [os.path.join(BASE_DIR, 'templates')]
        •        STATICFILES_DIRS:
          •   STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'statics'), )
          •       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
    • STATIC_URL的使用说明
      • STATICFILES_DIRS路径的别名,在html页面中引用js、css时,路径要使用STATIC_URL
      • 例如:<script src="/static/Semantic-UI-CSS-master/semantic.min.js"></script>
  • 相关阅读:
    Log4Net 发布后不能用
    主机ping不通虚拟机
    c# Delegate 和 Events
    ADO.NET
    .NET Windows Service
    Linux 常用命令三 touch mkdir
    Linux 常用命令二 pwd cd
    Linux 常用命令一 ls
    python 面向对象六 动态添加方法 __slots__限制动态添加方法
    python 面向对象六 类属性和实例属性
  • 原文地址:https://www.cnblogs.com/dongmengze/p/9668939.html
Copyright © 2011-2022 走看看