随笔分类 -  django

摘要:https://docs.djangoproject.com/en/dev/ref/models/expressions/ from django.db.models import Count, F, Value from django.db.models.functions import Leng 阅读全文
posted @ 2020-10-16 13:35 花生与酒 阅读(418) 评论(0) 推荐(0)
摘要:利用django-axes 控制用户尝试登陆次数,失败若干次后封锁IP禁止登陆 1.install pip install django-axes # バージョンを指定する場合は以下 pip install django-axes==5.0.13 settings.py添加 INSTALLED_AP 阅读全文
posted @ 2020-10-16 11:47 花生与酒 阅读(173) 评论(0) 推荐(0)
摘要:pk使用uuid,字段校验 models.py import uuid from django.core.validators import RegexValidator from django.db import models class Customer(models.Model): id = 阅读全文
posted @ 2020-10-16 11:01 花生与酒 阅读(207) 评论(0) 推荐(0)
摘要:django 模板系统 有很多标签,其中cycle我觉得不好理解,至少网上文档也不好理解。 这些标签可以通过渲染模板文件而获得我们预期的效果和文字,常用的有如下这些标签: 标签:{% 标签名 %}{% if 变量 %} 支持not or and,空对象空的玩意0默认为False{% else %}{ 阅读全文
posted @ 2020-10-13 14:36 花生与酒 阅读(874) 评论(0) 推荐(0)
摘要:一、Django ModelForm: accessing a field's value in the view template template中,读取modelForm的数据,并显示(而不是录入) Since you're trying to get this data from a fil 阅读全文
posted @ 2020-10-13 09:22 花生与酒 阅读(134) 评论(0) 推荐(0)
摘要:How do I convert a Django QuerySet into list of dicts? https://stackoverflow.com/questions/7811556/how-do-i-convert-a-django-queryset-into-list-of-dic 阅读全文
posted @ 2020-10-09 16:24 花生与酒 阅读(299) 评论(0) 推荐(0)
摘要:For retrieving the data, you have two options: 1) You can create Django models that correspond to your tables in the MySQL database. You can do this m 阅读全文
posted @ 2020-09-03 12:49 花生与酒 阅读(294) 评论(0) 推荐(0)
摘要:创建app (添加到installed apps)python manage.py startapp test_worm依赖文件生成pip freeze > requirements.txt依赖文件安装pip install -r requirements.txt添加静态资源,在settings.p 阅读全文
posted @ 2020-07-22 10:11 花生与酒 阅读(241) 评论(0) 推荐(0)
摘要:可以用send_mail 也可以用EmailMessage send_mail简单易用,是对EmailMessage的简单封装。但还是EmailMessage更强大 https://docs.djangoproject.com/en/3.0/topics/email/ 官网对EmailMessage 阅读全文
posted @ 2020-07-03 11:21 花生与酒 阅读(110) 评论(0) 推荐(0)
摘要:一、最常规,不定制custom的方式 from django.contrib.auth.models import User class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) ti 阅读全文
posted @ 2020-06-28 09:19 花生与酒 阅读(1029) 评论(0) 推荐(0)
摘要:注意,本文是作者自己备份用,django oracle相关技术资料,请参考 oracle-django总结 https://stackoverflow.com/questions/4914775/django-inspectdb-issue-using-oracle-database https:/ 阅读全文
posted @ 2020-06-02 20:04 花生与酒 阅读(308) 评论(0) 推荐(0)
摘要:一、正常流程 1.python manage.py makemigrations 或 python manage.py makemigrations appname 2. Python manage.py migrate python manage.py migrate appname 二、由于某种 阅读全文
posted @ 2020-03-31 10:06 花生与酒 阅读(6992) 评论(0) 推荐(0)
摘要:一、我的做法 设置2个参数,根据操作对象做切换。 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'lxg', 'USER': 'myname', 'PASSWORD': 'mypass', 'HOST 阅读全文
posted @ 2020-03-27 21:09 花生与酒 阅读(315) 评论(0) 推荐(0)
摘要:1.pycharm环境 https://www.django.cn/article/show-16.html 2.django语法以及入门 https://www.django.cn/course/show-18.html 3.中文网,入门文章多 https://www.django.cn/ 阅读全文
posted @ 2020-03-27 16:25 花生与酒 阅读(176) 评论(0) 推荐(0)
摘要:相关url: 重点讲解filter,有相关例子: https://www.cnblogs.com/ywhyme/p/11720696.html 官网关于model自带的函数: https://docs.djangoproject.com/en/2.2/ref/models/querysets/ ht 阅读全文
posted @ 2020-03-12 11:53 花生与酒 阅读(515) 评论(0) 推荐(0)
摘要:问题一:pl/sql工具查询导出问题 常识用pl/sql工具查询,导出, 特别慢,一千万条以上的数据,数据量超过了1G, 预计需要几个小时, 主要在pl/sql页面上显示时间太长。 有时候报错“结果集超过了最大长度100mb”, 可以通过plsql的设置:TOOLS-- PREFERENCES-WI 阅读全文
posted @ 2020-02-28 10:41 花生与酒 阅读(630) 评论(0) 推荐(0)
摘要:A middleware factory is a callable that takes a get_response callable and returns a middleware. A middleware is a callable that takes a request and re 阅读全文
posted @ 2020-01-03 09:07 花生与酒 阅读(250) 评论(0) 推荐(0)
摘要:1.自定义的middleware写好后,要注册在setting中。系统也自带若干middleware。 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middlewar 阅读全文
posted @ 2020-01-02 09:25 花生与酒 阅读(151) 评论(0) 推荐(0)
摘要:增加: 一篇不多的form+modelform,值得看看 https://blog.csdn.net/Burgess_zheng/article/details/86658260 一、基本设置 from django.forms import widgets所有的插件配置 widget变量设置,wi 阅读全文
posted @ 2019-11-27 11:31 花生与酒 阅读(232) 评论(0) 推荐(0)
摘要:请看上传的文件 阅读全文
posted @ 2018-03-13 10:12 花生与酒 阅读(394) 评论(1) 推荐(0)