title: How can I create a deep clone of a DB object in Django?
body: <p>I am trying to create a complete copy of a survey instance, which has several sections, and each section has several questions and finally each question has several options. I am using standard django 1.3.1, with MySQL. I need to be able to create a complete copy of all these elements, for a different survey owner. What I currently have in the view is:</p>
  
  <pre><code>    survey_new = survey
      survey_new.title = survey.title + ' -- Copy'
      survey_new.owner = str(new_owner_id)
      survey_new.created = datetime.now()
      survey_new.pk = None
      survey_new.save()
  
      for sec in survey.sections.all().order_by('order'):
          sec_n = sec
          sec_n.survey_id = survey_new.id 
          sec_n.pk = None
          sec_n.save()
  
          for q in sec.questions.all().order_by('order'):
              q_n = q
              q_n.section_id = sec_n.id
              q_n.pk = None
              q_n.save()
  
              for op in q.options.all().order_by('order'):
                  op_n = op
                  op_n.question_id = q_n.id
                  op_n.pk = None
                  op_n.save()
  </code></pre>
  
  <p>However, this seems to run through all the loops without any errors, and just creating a copy of survey. I was hoping that this would copy the survey, sections, questions, options for that survey instance. Just can't seem to figure out what I am doing wrong here.</p>