def pre_save(sender, model):
    """ Hash the password if being changed """

    if isinstance(model, Model) and 'password' in model.dirty_fields:
        model.salt, model.password = gen_salt_and_hash(model.password)
def pre_save ( sender , model ) : if isinstance ( model , Model ) and 'password' in model . dirty_fields : model . salt , model . password = gen_salt_and_hash ( model . password )
Hash the password if being changed