def set_study_id(sender, **kwargs): pre_save.disconnect(set_study_id, sender=Study) study = kwargs['instance'] data_group_id = db.get_data_group_id(study.data_group) study.study_id = db.get_study_id(study.name, data_group_id) if study.study_id != None: study.save() pre_save.connect(set_study_id, sender=Study)
def set_study_id(sender, **kwargs): pre_save.disconnect(set_study_id, sender=Study) study = kwargs['instance'] print 'getting data group id' data_group_id = db.get_data_group_id(study.data_group) print data_group_id study.study_id = db.get_study_id(study.name, data_group_id) print study.study_id if study.study_id is not None: study.save() pre_save.connect(set_study_id, sender=Study)