随笔分类 - Django类
部署django
摘要:搭建uWSGI工作环境 在 WSGI 协议中定义了两个角色:一个是 Web 服务器即 server,另一个是应用程序即 application,server 需要接受来自客户端的请求,然后根据协议定义调用应用程序(application),应用程序处理请求并返回结果给 server,最终响应给客户端
Django--StreamingHttpResponse下载文件
摘要:from django.shortcuts import render, HttpResponse from django.http import StreamingHttpResponse import os def index(request): return render(request,"i
django模板中导入js、css等静态文件
摘要:打开settings.py,在底部添加: import os STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(os.path.dirname(__file__), '../static/').replace('\\','/'), )
Django QuerySet API---数据库接口
摘要:基本的创建与查询 # -*- coding: utf-8 -*- from django.http import HttpResponse from TestModel.models import Test """# 数据库操作--新建数据 def testdb(request): test1 =
Django 模型(数据库)-cmd下的操作
摘要:Django 模型是与数据库相关的,与数据库相关的代码一般写在 models.py 中,Django 支持 sqlite3, MySQL, PostgreSQL等数据库,只需要在settings.py中配置即可,不用更改models.py中的代码,丰富的API极大的方便了使用。 1. 新建项目和应用