什么时候用save什么时候用signal

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

你可能感兴趣的:(django)