title: Why is my Django SessionWizardView Survey Application Data not showing up in a usable format in my MySQL Database?
body: <p>I have built a multi-page survey application using a <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/formtools/form-wizard/" rel="nofollow noreferrer">Django 1.6.2 SessionWizardView</a> but I am having some trouble with how the data submitted through the survey form is being saved in my MySQL database <code>django_db</code>. That is I simply do not recognize or understand what is being saved. This is my first time building an application like this or even working with a databases so please forgive my ignorance. </p>
  
  <p>My problem is that when I look at my database via phpMyAdmin nothing is recognizable as being from my application, So I have no idea where to start.</p>
  
  <p>I believe the data from my SessionWizardView should get stored in the <code>django_session</code> table but when I inspect it it looks like gibberish. </p>
  
  <p><img src="https://i.stack.imgur.com/qZ83I.png" alt="enter image description here"></p>
  
  <p>Here is a copy of the <code>session_data</code>- Is this what I am meant to be looking at?</p>
  
  <pre><code>ZTEwNWUzZmI4NjA5MmQ3Nzk2MDQ1MWY3YzE2MjYxZWZjNDJmODQ3Yjp7ImVpZ2h0X2ltYWdlIjoiUDFEOS5qcGciLCJwYXRoX3R3b19pbWFnZXMiOltdLCJwYXRoX29uZV9pbWFnZXMiOltdLCJ0aGlyZF9pbWFnZSI6IlA5RDguanBnIiwiaW1hZ2VzIjpbXSwid2l6YXJkX3N1cnZleV93aXphcmRfb25lIjp7InN0ZXBfZmlsZXMiOnt9LCJzdGVwIjpudWxsLCJleHRyYV9kYXRhIjp7fSwic3RlcF9kYXRhIjp7fX0sInNpeHRoX2ltYWdlIjoiUDVENC5qcGciLCJmb3VydGhfaW1hZ2UiOiJQNEQzLmpwZyIsImZpZnRoX2ltYWdlIjoiUDJEMS5qcGciLCJ3aXphcmRfc3VydmV5X3dpemFyZF90d28iOnsic3RlcF9maWxlcyI6e30sInN0ZXAiOm51bGwsImV4dHJhX2RhdGEiOnt9LCJzdGVwX2RhdGEiOnt9fSwicGF0aF90aHJlZV9pbWFnZXMiOlsiUDNEMS5qcGciLCJQNEQyLmpwZyIsIlA1RDMuanBnIiwiUDZENC5qcGciLCJQN0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cnNTckhoRkVoTjciXSwiMi1ub3RoaW5nIjpbIiJdLCJzdXJ2ZXlfd2l6YXJkX3RocmVlLWN1cnJlbnRfc3RlcCI6WyIyIl0sInN1Ym1pdCI6WyJOZXh0Il19fX19
  </code></pre>
  
  <h1>Questions:</h1>
  
  <ol>
  <li><p>Can someone take a look at my process/code below and tell me if I am
  missing a step, or have not included something in my code?</p></li>
  <li><p>Am I missing something at the MySQL end? Should I be creating
  specific tables or somehow customizing it so that it stores the data
  in a useable/readable format?</p></li>
  <li><p>Am I even looking in the right place for completed survey
  application data? Where does a SessionWizardView store/send it?</p></li>
  </ol>
  
  <p>Once again this is my first database application so thank you for your patients</p>
  
  <h1>Process:</h1>
  
  <ul>
  <li><p>I created the database in MySQL (Ver 14.14 Distrib 5.6.20) via
  Terminal <code>CREATE database django_db;</code> and the tables in it are
  created when I run the command <code>python manage.py syncdb</code> Other than
  that I do not touch the database. </p></li>
  <li><p>I can complete my survey built using the SessionWizardView both on my
  local machine and on the public server. No errors and it apepars
  everything works fine</p></li>
  <li><p>I have setup phpMyAdmin and can see the <code>django_db</code> database. However
  I don't really know what I am looking at.</p></li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/D4NXS.png" alt="enter image description here"></p>
  
  <h1>Code:</h1>
  
  <p><strong>forms.py</strong></p>
  
  <p>For the most part the survey has relatively simple questions such as:</p>
  
  <pre><code>class SurveyFormA(forms.Form):
  
  #When were you born?
      birthdate = forms.DateField(widget=extras.SelectDateWidget(years = range(1995, 1900, -1)), label='What is your Date of Birth?', required = False)
  
  #What is your current relationship status?   
      SINGLE = 'Single'
      INARELATIONSHIP = 'In a relationship'
      MARRIED = 'Married'
      DIVORCED = 'Divorced' 
      SEPARATED = 'Separated'
      WIDOWED = 'Widowed'
  
      RELATIONSHIP = (
          ("", "----------"),            
          (SINGLE, "Single"),
          (INARELATIONSHIP, "In a relationship"),
          (MARRIED, "Married"),
          (DIVORCED, "Divorced"),
          (SEPARATED, "Separated"),
          (WIDOWED, "Widowed"),
                 )    
      relationship = forms.ChoiceField(widget=forms.Select(), choices=RELATIONSHIP, initial= "", label='What is your relationship status?', required = False)            
  
  class SurveyFormB(forms.Form): #Internet usage questions
  
     (second page questions here)
     ....
     ....
  </code></pre>
  
  <p>These seem to work fine as you can see in the image below
  <img src="https://i.stack.imgur.com/eqcrB.png" alt="enter image description here"></p>
  
  <p>Each of the SessionWizardViews has a <code>get_context_data</code> used for captureing and storing data from one page of the survey form to the next and <code>done</code> method. I am not showing the full <code>get_context_data</code> as it is quite long. </p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class SurveyWizardOne(SessionWizardView):                             
      def get_context_data(self, form, **kwargs):
          context = super(SurveyWizardOne, self).get_context_data(form, **kwargs)  
          ....   
          ....                 
  
      def done(self, form_list, **kwargs):
          return render(self.request, 'Return_to_AMT.html', {
              'form_data': [form.cleaned_data for form in form_list],            
          }) 
  </code></pre>
  
  <h1>Database Connection:</h1>
  
  <p>My Django site is connected to a MySQL database in settings.py</p>
  
  <pre><code>DATABASES = {
      'default': { 
          'ENGINE': 'django.db.backends.mysql', 
          'NAME': 'django_db',                                       
          'USER': 'root',
          'PASSWORD': '************',
          'HOST': '127.0.0.1',
          #'PORT': '', 
      }
  }
  </code></pre>