Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Rewrite save in model when django data is saved

Shulou Source: shulou.com Published: 2022-06-02 04:42:25 10月02日 Update

This article mainly explains "rewrite save in model when django data is saved", the content of the explanation in the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "django data preservation in model rewrite save" bar!

Requirements: class Article (Model.model):

Title =''

Title_hash = hash (title)

Implementation method 1:def save (self, * args, * * kwargs):

Self.title_hash = hash (self.title)

Super (Article, self) .save (* args, * * kwargs)

Implementation method 2:def save_title_hash (self):

Title_hash = hash (title)

Return title_hash

Title_hash = property (save_title_hash) Thank you for your reading, the above is the content of "rewrite save in model when django data is saved". After the study of this article, I believe you have a deeper understanding of the problem of rewriting save in model when saving django data, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data learning content way that is ideas situations articles more knowledge knowledge points articles follow questions requirements practice push research verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi vpn Linux macOS