title: Sending a list as a context variable and back again via POST
body: <p>Suppose in my view, I have a list of strings, which I send as a context variable to a template. Then in that template, there is a form which is submitted. One of the fields on that form is a hidden field, and set to equal this list from the context. Back in my view, when I then read this list from the request's POST object, the list seems to have separated out all the characters from the original list, and set each character to its own element.</p>
  
  <p>For example, if my original list is ['alpha', 'beta'], then the list returned from my template via the request's POST object appears as ['a', 'l', 'p', 'h', 'a', 'b', 'e', 't', 'a'].</p>
  
  <p>1) Why does this happen?</p>
  
  <p>2) How can I keep the original format?</p>
  
  <p>Here's the relevant code from my template:</p>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;input type="hidden" name="class_names" value="{{ class_names }}"/&gt;
      &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>where <code>class_names</code> is the list passed as a context variable in the view:</p>
  
  <pre><code>class_names = ['alpha', 'beta']
  context = {'class_names': class_names}
  return render(request, 'teacher/query.html', context)
  </code></pre>
  
  <p>and then in the view when I extract this list from the request:</p>
  
  <pre><code>class_names = request.POST['class_names']
  for x in _class_names:
      print x
  </code></pre>
  
  <p>it prints out each individual character, rather than each word in the list.</p>