《Django 5 By Example》阅读笔记:p383-p387

《Django 5 By Example》读后感 本人的工作方向为Python Web方向,想了解下今年该方向有哪些新书出版,遂上packt出版社网站上看了看,发现这本书出版时间比较新(2024年9月),那就它了。从2024年11月11日至2024年12月18日期间,花了 22 天阅读完《Django 5 By Example》(《Django项目实例精解》)。 阅读详情

《Django 5 By Example》学习第 14 天,p383-p387 总结,总计 5 页。

一、技术总结

1. asynchronous task(异步任务)

对于异步任务,书中使用的是 celery 和 RabbitMQ,这也是平时工作中的主流用法。

(1) celery

Python 使用的 celery 包的名字也是 celery。

2. RabbitMQ

(1) 拉取镜像

docker pull rabbitmq:4.0.4-management

书中是使用的镜像是 rabbitmq:3.13.1-management,虽然每个作者大多忽略说明为什么选择某个版本的镜像,但我觉得还是有必要说明一下。为什么镜像要选择带 management 的镜像呢?因为带 management 的版本自带 web 管理界面,否则无法直接访问。下面是对比:

1)rabbitmq:4.0.4-management 镜像

使用 5672 和 15672 端口。

在这里插入图片描述

2)rabbitmq:4.0.4 镜像

为了演示,使用 5673 和 15673 端口。

在这里插入图片描述

否则需要手动启用 rabbitmq_management 才可以访问 web 管理界面:

docker exec -it rabbitmq bash
rabbitmq-plugins enable rabbitmq_management

(2) docker compose部署

rabbitmq:
    image: rabbitmq:4.0.4-management
    container_name: rabbitmq
    restart: always
    ports:
      - "5672:5672" # RabbitMQ Messaging Port
      - "15672:15672" # RabbitMQ Management UI
    volumes:
      - /data/rabbitmq/data:/var/lib/rabbitmq/
      - /data/rabbitmq/log:/var/log/rabbitmq

二、英语总结(生词:0)

无。

三、其它

docker-compose.yml 不能使用 tab 缩进!不能使用 tab 缩进!不能使用 tab 缩进!时间都去哪了~ 时间都用在找 bug 了。
在这里插入图片描述

四、参考资料

1. 编程

(1) Antonio Melé,《Django 5 By Example》:https://book.douban.com/subject/37007362/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org
在这里插入图片描述

欢迎搜索及关注:编程人(a_codists)

别再只调A*算法了!聊聊ROS机器人导航中,OpenCV视觉信息如何与激光雷达数据“打配合” 本文探讨了ROS机器人导航中激光雷达与OpenCV视觉融合的实战策略,揭示了如何通过多模态感知提升导航精度。文章详细介绍了视觉特征到代价地图的转化方法、系统级挑战的工程解决方案,以及融合感知下的路径规划进化,帮助开发者优化机器人导航系统。 阅读详情

相关推荐

国产HDMI2.0芯片GSV2011怎么选?手把手教你用它设计音视频采集卡(附FPGA/海思对接指南)

本文详细解析国产HDMI2.0芯片GSV2011在音视频采集卡设计中的应用,涵盖芯片选型、硬件设计要点及与FPGA/海思平台的对接指南。GSV2011凭借4K@60Hz支持、音频提取嵌入功能和高集成度,成为音视频设备的核心选择,助力开发者快速实现高性能采集卡设计。

weixin_30181209的博客 337

《Django 5 By Example》阅读笔记:p679-p765

书里通过聊天软件功能演示Django中channel以及异步编程的应用,本人对这块不是很熟悉,不做评价。(1)engage: en-(“in”) + gage(“a pledge, commitment, or security,保证,承诺”)。

codists的博客 1046

modelsim软件安装教程及踩坑(极简版)

1.安装的网盘链接:链接:https://pan.baidu.com/s/1ltUfssyXlCnqDmLhWyhlwA提取码:jery 2.步骤(参考博文):https://blog.youkuaiyun.com/weixin_42693097/article/details/90523692?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163521788716780357213801%2522%252C%2522scm%2522%253A%2522

subtitle_的博客 3781

《Django 5 By Example》阅读笔记:p237-p338

表之间的关系有三种:OneToOneField,many-to-one(使用Foreignkey()),ManyToManyField。

codists的博客 731

给IC设计新人的Tessent Scan入门指南:从RTL到ATPG的完整DFT流程解析

本文为IC设计新手提供Tessent Scan的完整DFT流程指南,从RTL代码检查到ATPG测试向量生成,详细解析扫描链配置、插入及验证的关键步骤。通过实战案例和工具命令示例,帮助工程师快速掌握Tessent工具链的应用技巧,提升芯片可测试性设计的效率和质量。

weixin_32541663的博客 452

ESP32连接PDM麦克风操作指南:新手入门必看

手把手教你如何将ESP32与PDM麦克风连接,采集音频数据并用于音频分类应用。内容涵盖硬件接线、代码配置及实际调试技巧,适合初学者快速上手esp32在声音识别场景中的使用。

weixin_42590539的博客 1330

《Django 5 By Example》阅读笔记:p521-p542

django-parler 用于 model 的 translate。这里要注意下,使用 django-parler 之后会生成新的表,对原来的表数据有影响。本人未在实际项目中做过国际化开发,但个人觉得这种做法不好。vt. fit one thing to another(适应)。

codists的博客 854

gm/ID设计方法实践指南:从理论曲线到电路优化的关键步骤

本文详细介绍了gm/ID设计方法在模拟IC设计中的实践指南。该方法通过直接利用工艺模型数据,将设计焦点从盲目调整晶体管尺寸转向选择关键的gm/ID工作点,从而在先进工艺下实现功耗、增益和带宽等性能的精准权衡与优化。文章从理论曲线生成到具体电路设计步骤,提供了完整的实战流程。

pandas7gardener的博客 480

《Django 5 By Example》阅读笔记:p1-p16

《Django 5 By Example》学习第1天,p1-p16总结,总计16页。 (2)定义model (3)启动项目 二、英语总结(生词:8) 1.fintech abbreviation for financial technology: the business of using technology to offer financial services in new ways。He joined Backbase in 2023, following its acquisition of N

codists的博客 1000

PWM调光原理详解:为什么你的LED灯会闪烁?从硬件到软件的避坑指南

本文深入解析PWM调光原理,揭示LED灯闪烁的根本原因,并提供从硬件设计到软件算法的全面解决方案。通过分析人眼视觉暂留机制和PWM参数设置,帮助开发者避免频闪问题,提升照明质量。特别适合电子工程师和智能家居开发者参考。

weixin_29189363的博客 297

STM32多模式智能小车状态机设计与中断优先级实践

在嵌入式实时系统中,状态机是实现多任务协同与功能切换的核心范式。其本质是通过有限状态集合、明确转移条件和确定性动作,构建可预测、易维护的控制逻辑。基于STM32等资源受限MCU时,需兼顾状态调度效率、中断并发安全与硬件资源约束。关键技术价值体现在:提升系统模块解耦度、支持物理按键与蓝牙双源触发、保障实时响应不丢帧。典型应用场景包括智能小车多模运行(循迹、避障、遥控、定距跟随等)、工业设备工作模式切换及IoT终端低功耗状态管理。本文以STM32F103C8T6平台为例,深入解析全局模式变量设计、双通道状态切换

weixin_42509888的博客 95

《Django 5 By Example》阅读笔记:p543-p550

Afixture。

codists的博客 1260

self‑improving‑agent 安装与配置指南(OpenClaw)

长期记忆错误反思用户偏好学习持续进化AI → 反思 → 学习 → 改进。

tiantiantbtb的博客 1342

《Django 5 By Example》阅读笔记:p17-p53

数据库迁移c. one side of a multi-sided object.本意多面物体(例如钻石)的某一面,在这里表示“a specific aspect of information”或者“a specific dimension of information”.

codists的博客 1076

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

《Django 5 By Example》阅读笔记:p339-p358

vt. to persuade sb forcefully to do sth(强制)。

codists的博客 1312

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

《Django 5 By Example》阅读笔记:p645-p650

Serializer又细分为Serializer, ModelSerializer, HyperlinkedModelSerializer.c. a piece of thick paper, leather or plastic that you put betweent the pages of a book so that you can find a page again quickly(书签).

codists的博客 939

《Django 5 By Example》阅读笔记:p493-p520

以前总觉得这两个缩写好难记,今天仔细看了下维基百科,“i18n” 中的 i 代表 “internationalization” 的第一个字母 i,n 代表最后一个字母 n, 18 代表 i 和 n 中间有 18 个字母。“L10n” 中的 i 代表 “localization” 的第一个字母 l,n 代表最后一个字母 n, 10 代表 l 和 n 中间有 10个字母。使用大写L 是因为小写的 l(L的小写) 和 大写的 I(i 的 大写)差不多一样,所以使用大写,其实大小写都可以。

codists的博客 1062

《Django 5 By Example》阅读笔记:p105-p164

Django自带django-taggit。这里使用的是Postgresql,使用pip install psycopg安装后,执行“pythonmanage.pymigarte”会报ModuleNotFoundError: No module named 'psycopg2’错误。应该按照文档使用pip install "psycopg[binary,pool]"进行安装。

codists的博客 974

《Django 5 By Example》阅读笔记:p651-p678

(1)aggregate:ad-(“to”) + gregare(“to collection into a flock(群), to gather”)因为ad 后面跟的是gregate,为了发音方便,ad演变为了ag。aggregate的本意是:vt. to combine into a single group(聚合, multiple things > single group)。示例:The butterflies aggregate in dense groups(蝴蝶聚集在一起).

codists的博客 988

《Django 5 By Example》阅读笔记:p614-p644

Django自带的缓存有:since accessing memory is faster than accessing data from databases of files(为了获得最佳性能,请使用基于内存的缓存后端,如Memcached或Redis,因为访问内存比从数据库或文件访问数据要快)其实我很想知道既然 Memcached 和 Redis 都是基于内存,那么该怎么选择呢?

codists的博客 691

《Django 5 By Example》阅读笔记:p211-p236

adv. without any interruption(连续地).

codists的博客 1158

《Django 5 By Example》阅读笔记:p388-p454

我觉得书中这种用法太简单了。adj. happening regularly(定期的)。

codists的博客 998

《Django 5 By Example》阅读笔记:p561-p613

(1)定义(什么是 mixins?(2)适用场景(为什么使用?vt. to keep safe, preserve from loss or decay(保护,节省)。p607, caching helps conserve computing power and reduces the need to query the database each time students access the same materials(缓存有助于节省计算能力,并减少学生每次访问相同材料时查询数据库的需要)。

codists的博客 676

《Django 5 By Example》阅读笔记:p165-p210

(1)登录认证作者这里使用的是Django自带的auth。(2)上传头像图片处理,使用Pillow。(3)扩展user扩展user模型与自带的user使用外键进行关联,命名为profile。p202, Pillow is the de facto standard library for image processing in Python. de facto不完全等于in fact, 可以理解为虽然不是法律上或者标准上,但在实际中被认为是。

codists的博客 761

《Django 5 By Example》阅读笔记:p54-p75

(1)分页:Paginator(2)页数不存在处理: EmptyPage, PageNotAnInteger(1)canon。

codists的博客 768

《Django 5 By Example》阅读笔记:p455-p492

(1)打折功能使用折扣码实现,但是折扣码是手动生成的,感觉实际业务中应该不是这样的。(2)推荐功能使用 Redis 做缓存,结合商品的销量做推荐,算是一种普通的实现方案。c. a piece of paper that can be used to buy sth at a reduced price(优惠券)。

codists的博客 739
上一篇: 《Django 5 By Example》阅读笔记:p339-p358
下一篇: 《Django 5 By Example》阅读笔记:p388-p454
codists
博客等级 码龄6年 1488粉丝 379原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值