Always use the redefinition of the save-method, when ...
* you check given values
* you create directories or files (directly connected to the data model) e.g. I create a new directory for each new Memory
* you are auto-populating fields, like James Bennett explains.
* you do any action directly connected to the model you are operating on
Always use signals, when ...
* you want to report that something was added or changed
* you want to save new data-sets, which are associated to this model - e.g. when a new user is added to the system and you want to set the the default values of the website-settings (in case it is separated from User and UserProfile) - e.g. when a new user is added and you want to save a Welcome! Message into the internal Private Messaging system
* you check given values
* you create directories or files (directly connected to the data model) e.g. I create a new directory for each new Memory
* you are auto-populating fields, like James Bennett explains.
* you do any action directly connected to the model you are operating on
Always use signals, when ...
* you want to report that something was added or changed
* you want to save new data-sets, which are associated to this model - e.g. when a new user is added to the system and you want to set the the default values of the website-settings (in case it is separated from User and UserProfile) - e.g. when a new user is added and you want to save a Welcome! Message into the internal Private Messaging system
本文探讨了在软件开发中如何正确使用模型保存方法及信号(signals)。在直接操作数据模型如创建目录或文件、自动填充字段等场景下推荐使用save方法;而当需要报告新增或更改的数据、保存与当前模型相关的新数据集时,则建议采用信号机制。

被折叠的 条评论
为什么被折叠?



