09 2019 档案

摘要:models.py: from django.db import models from django.contrib.auth.models import AbstractUser class UserInfo(AbstractUser): phone = models.CharField(max 阅读全文
posted @ 2019-09-17 16:49 Sch01aR# 编辑
摘要:生成数据库 查看 auth_user 数据库 给 auth_user 表创建一个超级用户 邮箱地址可以不写 再看一下 auth_user 表 密码被加密了 login.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 阅读全文
posted @ 2019-09-15 15:39 Sch01aR# 编辑
摘要:process_template_response(self, request, response) 有两个参数,response 是 TemplateResponse 对象(由视图函数或者中间件产生) process_template_response 函数是在视图函数执行完后立即执行的 执行 p 阅读全文
posted @ 2019-09-13 17:12 Sch01aR# 编辑
摘要:process_exception(self, request, exception) 函数有两个参数,exception 是视图函数异常产生的 Exception 对象 process_exception 函数的执行顺序是按照 settings.py 中设置的中间件的顺序的倒序执行 process 阅读全文
posted @ 2019-09-13 16:41 Sch01aR# 编辑
摘要:process_view 的执行顺序也是按照 settings.py 中的顺序来执行 process_view 在 urls.py 的对应关系之后,在执行视图函数之前执行 如果返回 None,则继续执行后面的中间件的 process_view 函数 如果返回 HttpResponse,则不执行后续的 阅读全文
posted @ 2019-09-13 14:36 Sch01aR# 编辑
摘要:process_response 函数是执行完 views.py 后执行的函数 process_response 函数有两个参数,一个是 request,一个是 response,response 是视图函数返回的响应对象 process_response 函数的返回值必须是 HttpRespons 阅读全文
posted @ 2019-09-12 20:40 Sch01aR# 编辑
摘要:process_request 函数是中间件在收到 request 请求之后执行的函数 该函数的执行顺序是按照 settings.py 中中间件的配置顺序执行的 如果该函数返回 None,继续执行后面的中间件的 process_request 方法 如果该函数返回 response,则不再继续执行后 阅读全文
posted @ 2019-09-12 18:33 Sch01aR# 编辑
摘要:importlib 模块可以根据字符串来导入相应的模块 目录结构: 在根目录下创建 importlib_test.py 和 aaa/bbb.py bbb.py: importlib_test.py: 运行结果: 阅读全文
posted @ 2019-09-11 20:45 Sch01aR# 编辑
摘要:中间件简介: 中间件是在 wsgi.py 之后,urls.py 之前,在全局操作 Django 请求和响应的模块 在 settings.py 中可以看到中间件的相关配置 该列表中的每一个元素都是一个类,一个中间件 例如: django.middleware.csrf.CsrfViewMiddlewa 阅读全文
posted @ 2019-09-11 18:37 Sch01aR# 编辑
摘要:app01/models.py: from django.db import models class UserInfo(models.Model): username = models.CharField(max_length=16) password = models.CharField(max 阅读全文
posted @ 2019-09-10 20:51 Sch01aR# 编辑
摘要:reg2.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>注册页面</title> <link rel="stylesheet" href="/static/bootstrap/css/boots 阅读全文
posted @ 2019-09-10 18:06 Sch01aR# 编辑
摘要:app01/models.py: from django.db import models class UserInfo(models.Model): username = models.CharField(max_length=16) password = models.CharField(max 阅读全文
posted @ 2019-09-07 16:45 Sch01aR# 编辑
摘要:app01/models.py: from django.db import models class UserInfo(models.Model): username = models.CharField(max_length=16) password = models.CharField(max 阅读全文
posted @ 2019-09-07 15:16 Sch01aR# 编辑
摘要:reg2 函数: from django.shortcuts import render, HttpResponse from app01 import models def reg2(request): form_obj = RegForm() # GET 请求 if request.method 阅读全文
posted @ 2019-09-06 22:01 Sch01aR# 编辑
摘要:邮箱: views.py: from django import forms from django.forms import widgets class RegForm(forms.Form): email = forms.EmailField( label="邮箱", widget=widget 阅读全文
posted @ 2019-09-05 22:39 Sch01aR# 编辑
摘要:普通 form 表单的处理: reg.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>注册页面</title> </head> <body> <form action="/reg/" method 阅读全文
posted @ 2019-09-05 18:32 Sch01aR# 编辑
摘要:SweetAlert Github:https://github.com/lipis/bootstrap-sweetalert 下载完后放入 /static/ 目录下 sweetalert.html: <!DOCTYPE html> <html lang="en"> <head> <meta cha 阅读全文
posted @ 2019-09-04 23:10 Sch01aR# 编辑
摘要:app01/__int__.py: import pymysql pymysql.install_as_MySQLdb() app01/models.py: from django.db import models class Person(models.Model): name = models. 阅读全文
posted @ 2019-09-03 22:11 Sch01aR# 编辑
摘要:index.html: <input type="text" id="i1">+ <input type="text" id="i2">= <input type="text" id="i3"> <input type="button" value="AJAX提交" id="b1"> <script 阅读全文
posted @ 2019-09-03 21:04 Sch01aR# 编辑
摘要:AJAX 局部刷新实例: 使用 jQuery 实现基本的发送 AJAX 请求 index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> ajax 局部刷新实例 </title> </head> 阅读全文
posted @ 2019-09-01 17:48 Sch01aR# 编辑

点击右上角即可分享
微信分享提示