title: Storing a users submitted jQuery values in a Python/Django view
body: <p>Below are two pieces of code (WORKING and BROKEN) which aim to do the same thing. Unfortunately my "working" solution is extremely ugly and ungainly, my broken code, not so much.</p>
  
  <p>As you will see below, my <strong>BROKEN CODE</strong> is a much nicer solution, unfortunately it dose not work. The main issue I have is that my slider does not have a value until the user moves it. Its default is 'None'. So therefore on step 5 I keep inserting a 'None' in my list instead of the users rating. </p>
  
  <p>If anyone can help me with this it would be very much appreciated. </p>
  
  <p><strong>BROKEN CODE</strong></p>
  
  <pre><code>class SurveyWizardOne(SessionWizardView):                          
      def get_context_data(self, form, **kwargs):
          context = super(SurveyWizardOne, self).get_context_data(form, **kwargs)  
          if self.steps.current in ['5','6','7','8','9','10','11','12','13','14','15','16']:
  
              step = int(self.steps.current)
  
              if step in (5, 6, 7):
                  image = random.choice(PATH_ONE_IMAGES)   
                  images.insert(step - 5, image)        
                  PATH_ONE_IMAGES.remove(image)
                  context['display_image'] = image
  
                  slider_value = self.request.POST.get('slider_value')
                  slider_DV_values.insert(step - 5, slider_value)
  
              elif step == 8:
                  context['first_image'] = images[0]
                  context['second_image'] = images[1]
                  context['third_image'] = images[2]                           
  
                  print 'The value of the first slider is:', slider_DV_values[0] 
                  print 'The value of the second slider is:', slider_DV_values[1] 
                  print 'The value of the third slider is:', slider_DV_values[2] 
  
  
              steps = ['5','6','7','9','10','11','13','14','15']              
              dv_steps = ['8','12','16']          
  
              context.update({'steps': steps,
                                  'dv_steps': dv_steps
                                   })
          return context 
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <blockquote>
    <p>The value of the first slider is: None </p>
    
    <p>The value of the second slider is -66</p>
    
    <p>The value of the third slider is: -37</p>
  </blockquote>
  
  <p><strong>WORKING CODE</strong></p>
  
  <p>The below code does work, and stores the correct values. But its just dam ugly!</p>
  
  <pre><code>images = [] 
  slider_DV_values = []
  
  
  class SurveyWizardOne(SessionWizardView):                         
      def get_context_data(self, form, **kwargs):
          context = super(SurveyWizardOne, self).get_context_data(form, **kwargs)  
          if self.steps.current in ['5','6','7','8','9','10','11','12','13','14','15','16']:
  
              step = int(self.steps.current)
  
              if step in (5, 6, 7):
                  image = random.choice(PATH_ONE_IMAGES)   
                  images.insert(step - 5, image)        
                  PATH_ONE_IMAGES.remove(image)
                  context['display_image'] = image 
  
                  if step == 6:  
                      slider_value = self.request.POST.get('slider_value')
                      slider_DV_values.insert(step - 5, slider_value)                    
  
                  elif step == 7:  
                      slider_value = self.request.POST.get('slider_value')
                      slider_DV_values.insert(step - 5, slider_value)                    
  
  
              elif step == 8:
                  context['first_image'] = images[0]
                  context['second_image'] = images[1]
                  context['third_image'] = images[2]        
  
                  slider_value = self.request.POST.get('slider_value')
                  slider_DV_values.insert(step - 5, slider_value)                    
  
                  print 'The value of the first slider is:', slider_DV_values[0] 
                  print 'The value of the second slider is:', slider_DV_values[1] 
                  print 'The value of the third slider is:', slider_DV_values[2] 
  
  
              steps = ['5','6','7','9','10','11','13','14','15']              
              dv_steps = ['8','12','16']          
  
              context.update({'steps': steps,
                              'dv_steps': dv_steps
                               })
          return context 
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <blockquote>
    <p>The value of the first slider is: -99 </p>
    
    <p>The value of the second slider is -66</p>
    
    <p>The value of the third slider is: -37</p>
  </blockquote>