上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 30 下一页
摘要: """ 由于django自带的sqlite数据库对日期不敏感,所以我们换成MySQL """ from django.db import models # Create your models here. """ 先写普通字段 之后再写外键字段 """ from django.contrib.aut 阅读全文
posted @ 2022-04-05 19:46 咖喱给给啊 阅读(24) 评论(0) 推荐(0)
摘要: from django.db import models from django.contrib.auth.models import User,AbstractUser # Create your models here. # 第一种:一对一关系 不推荐 # class UserDetail(mo 阅读全文
posted @ 2022-04-05 19:41 咖喱给给啊 阅读(84) 评论(0) 推荐(0)
摘要: from django.shortcuts import render,redirect,HttpResponse from django.contrib import auth # Create your views here. from django.contrib.auth.decorator 阅读全文
posted @ 2022-04-05 19:13 咖喱给给啊 阅读(401) 评论(0) 推荐(0)
摘要: """ 其实我们在创建好一个django项目之后直接执行数据库迁移命令会自动生成很多表 django_session auth_user django在启动之后就可以直接访问admin路由,需要输入用户名和密码,数据参考的就是auth_user表,并且还必须是管理员用户才能进入 创建超级用户(管理员 阅读全文
posted @ 2022-04-05 18:37 咖喱给给啊 阅读(26) 评论(0) 推荐(0)
摘要: from django.views.decorators.csrf import csrf_protect,csrf_exempt from django.utils.decorators import method_decorator """ csrf_protect 需要校验 针对csrf_pr 阅读全文
posted @ 2022-04-05 16:50 咖喱给给啊 阅读(12) 评论(0) 推荐(0)
摘要: 在静态文件夹中建一个js文件 内容: function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { var cookies = document.cookie.s 阅读全文
posted @ 2022-04-05 16:39 咖喱给给啊 阅读(24) 评论(0) 推荐(0)
摘要: 一些细节: 使用process_template_response的时候 需要在视图中这样写,这个东西你自己是想不到的,这个是别人规定好的,不是逻辑问题,是语法问题 def index(request): print('我是视图函数index') obj = HttpResponse('index' 阅读全文
posted @ 2022-04-05 16:18 咖喱给给啊 阅读(19) 评论(0) 推荐(0)
摘要: from django.views import View from django.utils.decorators import method_decorator """ CBV中django不建议你直接给类的方法加装饰器 无论该装饰器能都正常给你 都不建议直接加 """ # @method_de 阅读全文
posted @ 2022-04-05 05:36 咖喱给给啊 阅读(12) 评论(0) 推荐(0)
摘要: """ session数据是保存在服务端的(存?),给客户端返回的是一个随机字符串 sessionid:随机字符串 1.在默认情况下操作session的时候需要django默认的一张django_session表 数据库迁移命令 django会自己创建很多表 django_session就是其中的一 阅读全文
posted @ 2022-04-05 05:35 咖喱给给啊 阅读(77) 评论(0) 推荐(0)
摘要: """ 发展史 1.网站都没有保存用户功能的需求 所有用户访问返回的结果都是一样的 eg:新闻、博客、文章... 2.出现了一些需要保存用户信息的网站 eg:淘宝、支付宝、京东... 以登陆功能为例:如果不保存用户登陆状态 也就意味着用户每次访问网站都需要重复的输入用户名和密码(你觉得这样的网站你还 阅读全文
posted @ 2022-04-05 05:34 咖喱给给啊 阅读(19) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 30 下一页