I need to convert a Trigger on a MySQL table to Python/Django.
The Trigger loads a select into a cursor, loops through and creates the child records. Here it is:
DECLARE cur CURSOR FOR select id from eval_category;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur;
  det_loop: LOOP
    FETCH cur INTO ids;
    IF done THEN
      LEAVE det_loop;
    END IF;
    INSERT INTO eval_evaluationdetail 
    (evaluation_id, category_id) VALUES (NEW.id,ids);
  END LOOP;
CLOSE cur;
To convert this to Python, I modified the models.py as follows:
def save(self):
    super(Evaluation, self).save()
    for cat in Category.objects.all():
        self.EvaluationDetail.evaluation=self
        self.EvaluationDetail.category=cat
        self.EvaluationDetail.save()
This is the latest iteration, but it still doesn't work :( Any help would be greatly appreciated.
 
     
    