会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
武校长Python全栈课程
不好好学,白瞎老师讲这么好
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
下一页
2023年8月28日
request请求但脚本爬取
摘要: import requestsfrom lxml import etreeurl = "https://duanzixing.com/"headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/5
阅读全文
posted @ 2023-08-28 22:49 khalil12138
阅读(20)
评论(0)
推荐(0)
2023年8月15日
Django templatetags使用
摘要: web app文件夹下创建templatetags文件夹 templates文件夹下创建tags文件夹 templatetags文件夹下创建menu.py from django.template import Libraryregister = Library()@register.inclusi
阅读全文
posted @ 2023-08-15 12:26 khalil12138
阅读(50)
评论(0)
推荐(0)
2023年8月13日
Django Form钩子方法源码分析
摘要: 1. 用法 在Form类中定义名称为 clean_ + form字段名称 的方法 校验成功 返回 self.clean_data["字段名"] 校验失败 会raise 报错 2. 源码分析 先从is_valid 方法开始分析 当self._is_bound = True, self.errors 为
阅读全文
posted @ 2023-08-13 17:38 khalil12138
阅读(22)
评论(0)
推荐(0)
2023年8月10日
Django Ajax获取CSRF token
摘要: 方法一1. 在script标签里设置方法// using jQueryfunction getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = do
阅读全文
posted @ 2023-08-10 15:42 khalil12138
阅读(142)
评论(0)
推荐(0)
2023年8月9日
Django 离线脚本(数据库添加admin用户)
摘要: import osimport sysimport djangobase_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(base_dir)os.environ.setdefault('
阅读全文
posted @ 2023-08-09 11:53 khalil12138
阅读(42)
评论(0)
推荐(0)
Django Session 配置
摘要: SESSION_ENGINE = "django.contrib.sessions.backends.db"SESSION_CACHE_ALIAS = "default"SESSION_COOKIE_NAME = "sid"SESSION_COOKIE_PATH = "/"SESSION_COOKI
阅读全文
posted @ 2023-08-09 11:31 khalil12138
阅读(18)
评论(0)
推荐(0)
Django Redis 配置
摘要: CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/", "OPTIONS": { "CLIENT_CLASS": "django_redis.
阅读全文
posted @ 2023-08-09 11:27 khalil12138
阅读(24)
评论(0)
推荐(0)
2023年8月8日
编写加密组件
摘要: import hashlibfrom django.conf import settingsdef md5(data_string): obj = hashlib.md5(settings.SECRET_KEY.encode('utf-8')) obj.update(data_string.enco
阅读全文
posted @ 2023-08-08 16:36 khalil12138
阅读(11)
评论(0)
推荐(0)
2023年7月29日
Django Form源码分析(1) (TextInput)
摘要: 自定义视图函数test widget = forms.TextInput(attrs={'class': "form-control"}) 运行步骤 1. 初始化封装 设置默认值 封装结束 # widge.input_type = "text"# widge.template_name = "dja
阅读全文
posted @ 2023-07-29 15:40 khalil12138
阅读(106)
评论(0)
推荐(0)
Django Form源码分析(3) - 课后作业
摘要: 昨日课后作业(Form源码分析) 问题: 当浏览器请求方式为POST,form如何封装,封装后如何进行valid校验 答案: 1. 分析 form = LoginForm2(request.POST) 这行代码其实等于 form = LoginForm2(data = request.POST) 加
阅读全文
posted @ 2023-07-29 13:26 khalil12138
阅读(10)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
下一页
公告