摘要:
""" 由于django自带的sqlite数据库对日期不敏感,所以我们换成MySQL """ from django.db import models # Create your models here. """ 先写普通字段 之后再写外键字段 """ from django.contrib.aut 阅读全文
posted @ 2022-04-05 19:46
咖喱给给啊
阅读(29)
评论(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
咖喱给给啊
阅读(94)
评论(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
咖喱给给啊
阅读(410)
评论(0)
推荐(0)
摘要:
""" 其实我们在创建好一个django项目之后直接执行数据库迁移命令会自动生成很多表 django_session auth_user django在启动之后就可以直接访问admin路由,需要输入用户名和密码,数据参考的就是auth_user表,并且还必须是管理员用户才能进入 创建超级用户(管理员 阅读全文
posted @ 2022-04-05 18:37
咖喱给给啊
阅读(30)
评论(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
咖喱给给啊
阅读(13)
评论(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
咖喱给给啊
阅读(28)
评论(0)
推荐(0)
摘要:
一些细节: 使用process_template_response的时候 需要在视图中这样写,这个东西你自己是想不到的,这个是别人规定好的,不是逻辑问题,是语法问题 def index(request): print('我是视图函数index') obj = HttpResponse('index' 阅读全文
posted @ 2022-04-05 16:18
咖喱给给啊
阅读(22)
评论(0)
推荐(0)
摘要:
from django.views import View from django.utils.decorators import method_decorator """ CBV中django不建议你直接给类的方法加装饰器 无论该装饰器能都正常给你 都不建议直接加 """ # @method_de 阅读全文
posted @ 2022-04-05 05:36
咖喱给给啊
阅读(18)
评论(0)
推荐(0)
摘要:
""" session数据是保存在服务端的(存?),给客户端返回的是一个随机字符串 sessionid:随机字符串 1.在默认情况下操作session的时候需要django默认的一张django_session表 数据库迁移命令 django会自己创建很多表 django_session就是其中的一 阅读全文
posted @ 2022-04-05 05:35
咖喱给给啊
阅读(84)
评论(0)
推荐(0)
摘要:
# 虽然cookie是服务端告诉客户端浏览器需要保存内容 # 但是客户端浏览器可以选择拒绝保存 如果禁止了 那么 只要是需要记录用户状态的网站登陆功能都无法使用了 # 视图函数的返回值 return HttpResponse() return render() return redirect() o 阅读全文
posted @ 2022-04-05 05:34
咖喱给给啊
阅读(30)
评论(0)
推荐(0)
浙公网安备 33010602011771号